Image handling control panel
============================

First some initial setup code:

    >>> from plone.testing import z2
    >>> from plone.app.testing import SITE_OWNER_NAME, SITE_OWNER_PASSWORD
    >>> z2.login(layer['app']['acl_users'], SITE_OWNER_NAME)
    >>> from zope.component import getUtility
    >>> from Products.CMFCore.interfaces import IPropertiesTool
    >>> ptool = getUtility(IPropertiesTool)
    >>> iprops = ptool.imaging_properties
    >>> iprops.getProperty('allowed_sizes')
    ('large 768:768', 'preview 400:400', 'mini 200:200', 'thumb 128:128', 'tile 64:64', 'icon 32:32', 'listing 16:16')

    >>> from transaction import commit
    >>> commit()

Viewing the site control panel
------------------------------

    >>> from plone.testing.z2 import Browser
    >>> browser = Browser(layer['app'])
    >>> browser.addHeader('Authorization', 'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD))
    >>> browser.open('http://nohost/plone/@@imaging-controlpanel')
    >>> browser.url
    'http://nohost/plone/@@imaging-controlpanel'

Check for the icon to exist:

    >>> browser.contents
    '...<img src="http://nohost/plone/image_icon.png"...
     ...Image Handling...'

Click the cancel button:

    >>> browser.getControl(name="form.actions.cancel").click()
    >>> browser.url.endswith('plone_control_panel')
    True

There should be still no changes:

    >>> 'Changes canceled.' in browser.contents
    True

Make some changes
-----------------

    >>> browser.open('http://nohost/plone/@@imaging-controlpanel')
    >>> browser.url.endswith('imaging-controlpanel')
    True

    >>> browser.getControl(name='form.allowed_sizes.0.').value = 'foo 42:42'

Click the save button:

    >>> browser.getControl(name="form.actions.save").click()
    >>> browser.url.endswith('imaging-controlpanel')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in browser.contents
    True

Make sure the changes have been applied correctly:

    >>> iprops.getProperty('allowed_sizes')[0]
    u'foo 42:42'
    >>> from plone.app.imaging.utils import getAllowedSizes
    >>> getAllowedSizes()
    {...u'foo': (42, 42)...}

Change the quality
~~~~~~~~~~~~~~~~~~

    >>> browser.open('http://nohost/plone/@@imaging-controlpanel')
    >>> browser.url.endswith('imaging-controlpanel')
    True

    >>> browser.getControl(name='form.quality').value = '42'

Click the save button:

    >>> browser.getControl(name="form.actions.save").click()
    >>> browser.url.endswith('imaging-controlpanel')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in browser.contents
    True

Make sure the changes have been applied correctly:

    >>> iprops.getProperty('quality')
    42
    >>> from plone.app.imaging.utils import getQuality
    >>> getQuality()
    42
