Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use plone.app.robotframework

  • Loading branch information...
commit 9404fe37857c62e45711c1ede531126dd5ef6422 1 parent 1856225
@saily saily authored
View
5 CHANGES.txt
@@ -4,6 +4,11 @@ Changelog
0.1rc3 (unreleased)
-------------------
+- Use ``plone.app.robotframework`` instead of writing all keywords from
+ scratch. This brings us autologin support for faster robot tests. Rewrite
+ tests to test scenarios.
+ [saily]
+
- Drop Plone 4.1 support and tests.
[saily]
View
1  buildout.cfg
@@ -88,3 +88,4 @@ eggs = createcoverage
[versions]
Pillow = 2.4.0
selenium = 2.40.0
+plone.app.robotframework = 0.9.2
View
17 src/plone/app/imagecropping/testing.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+from plone.app.robotframework.testing import AUTOLOGIN_LIBRARY_FIXTURE
from plone.app.testing import FunctionalTesting
from plone.app.testing import IntegrationTesting
from plone.app.testing import PLONE_FIXTURE
@@ -22,8 +23,6 @@ def setUpZope(self, app, configurationContext):
plone.app.imagecropping,
context=configurationContext
)
- import plone.app.dexterity
- self.loadZCML(package=plone.app.dexterity)
def setUpPloneSite(self, portal):
applyProfile(portal, 'plone.app.imagecropping:testing')
@@ -32,7 +31,7 @@ def setUpPloneSite(self, portal):
['Manager'],
[])
login(portal, 'admin')
- portal.portal_workflow.setDefaultChain('simple_publication_workflow')
+ portal.portal_workflow.setDefaultChain('one_state_workflow')
setRoles(portal, TEST_USER_ID, ['Manager'])
portal.invokeFactory(
'Folder',
@@ -44,10 +43,14 @@ def setUpPloneSite(self, portal):
PLONE_APP_IMAGECROPPING = PloneAppImagecropping()
PLONE_APP_IMAGECROPPING_INTEGRATION = IntegrationTesting(
bases=(PLONE_APP_IMAGECROPPING, ),
- name='PLONE_APP_IMAGECROPPING:Integration')
+ name='plone.app.imagecropping:Integration')
PLONE_APP_IMAGECROPPING_FUNCTIONAL = FunctionalTesting(
bases=(PLONE_APP_IMAGECROPPING, ),
- name='PLONE_APP_IMAGECROPPING:Functional')
+ name='plone.app.imagecropping:Functional')
PLONE_APP_IMAGECROPPING_ROBOT = FunctionalTesting(
- bases=(PLONE_APP_IMAGECROPPING, z2.ZSERVER_FIXTURE),
- name='PLONE_APP_IMAGECROPPING:Robot')
+ bases=(
+ AUTOLOGIN_LIBRARY_FIXTURE,
+ PLONE_APP_IMAGECROPPING,
+ z2.ZSERVER_FIXTURE
+ ),
+ name='plone.app.imagecropping:Robot')
View
94 src/plone/app/imagecropping/tests/robot/keywords.robot
@@ -1,36 +1,12 @@
+*** Variables ***
+${TEST_FOLDER} = ${PLONE_URL}/acceptance-test-folder
*** Keywords ***
+i am logged in as a ${role}
+ Enable autologin as ${role}
-Suite Setup
- Open Browser ${front-page} browser=${BROWSER} desired_capabilities=Capture Page Screenshot
-
-Suite Teardown
- Close All Browsers
-
-Log in
- [Documentation] Log in to the site as ${userid} using ${password}. There
- ... is no guarantee of where in the site you are once this is
- ... done. (You are responsible for knowing where you are and
- ... where you want to be)
- [Arguments] ${userid} ${password}
-
- Go to ${PLONE_URL}/login_form
- Page should contain element __ac_name
- Page should contain element __ac_password
- Page should contain button Log in
- Input text __ac_name ${userid}
- Input text __ac_password ${password}
- Click Button Log in
-
-Log in as site owner
- [Documentation] Log in as the SITE_OWNER provided by plone.app.testing,
- ... with all the rights and privileges of that user.
- Log in ${SITE_OWNER_NAME} ${SITE_OWNER_PASSWORD}
-
-
-Create Image
- [Arguments] ${title}
- Go to ${test-folder}
+i create an image called '${title}'
+ Go to ${TEST_FOLDER}
Open Add New Menu
Click Link link=Image
@@ -48,14 +24,11 @@ Create Image
Page Should Contain Changes saved.
Page Should Contain Cropping
-
-Open Cropping Editor
+i click on the cropping tab
Click Link link=Cropping
- Page Should Contain Image Cropping Editor
+ Page Should Contain Element css=#coords
-
-Crop On Image Size
- [Arguments] ${scale} ${left} ${top}
+i crop the image size '${scale}' to ${left} x ${top}
Click Element xpath=//li[@data-scale_name=\"${scale}\"]/a
Wait Until Page Contains Element xpath=//form[@id=\"coords\"]/div[1]/div[1]
@@ -65,28 +38,13 @@ Crop On Image Size
Click Button name=form.button.Save
Page Should Contain Successfully saved cropped area
-
-Open Menu
- [Arguments] ${elementId}
- Element Should Not Be Visible css=dl#${elementId} dd.actionMenuContent
- Click link css=dl#${elementId} dt.actionMenuHeader a
- Wait until keyword succeeds 1 5 Element Should Be Visible css=dl#${elementId} dd.actionMenuContent
-
-
-Image Must Be Cropped
- Go to ${test-folder}/test-image/view
-
+image should be cropped
+ Go to ${TEST_FOLDER}/test-image/view
Page Should Contain Element xpath=//div[@id=\"content-core\"]//img[@width=\"232\" and @height=\"233\"]
- #Capture Page Screenshot after-crop.png
-
-
-Open Add New Menu
- Open Menu plone-contentmenu-factories
+ # Capture Page Screenshot after-crop.png
-
-Create dexterity content type with two image fields
- [Arguments] ${title}
- Go to ${test-folder}
+i create a two-image-field containing type called '${title}'
+ Go to ${TEST_FOLDER}
Open Add New Menu
Click Link link=dexterity content type with two image fields
Input text name=form.widgets.IDublinCore.title ${title}
@@ -96,17 +54,19 @@ Create dexterity content type with two image fields
Page Should Contain Item created
Page Should Contain Cropping
-
-Image Must Be Cropped For
- [Arguments] ${content-id} ${field-name}
- Go to ${test-folder}/${content-id}
- Execute JavaScript $('#form-widgets-${field-name} img').attr('src', '${test-folder}/${content-id}/@@images/${field-name}/preview').removeAttr('width').removeAttr('height').attr('width',$('#form-widgets-${field-name} img').width()).attr('height',$('#form-widgets-${field-name} img').height());
- Execute JavaScript $('#form-widgets-${field-name}').parent().parent().find('label').text('${field-name} size is ' + $('#form-widgets-${field-name} img').width() + 'x' + $('#form-widgets-${field-name} img').height());
+'${content-id}' image in field '${field-name}' should be cropped
+ Go to ${TEST_FOLDER}/${content-id}
+ Execute JavaScript $('#form-widgets-${field-name} img')
+ ... .attr('src', '${TEST_FOLDER}/${content-id}/@@images/${field-name}/preview')
+ ... .removeAttr('width')
+ ... .removeAttr('height')
+ ... .attr('width', $('#form-widgets-${field-name} img').width())
+ ... .attr('height', $('#form-widgets-${field-name} img').height())
+ Execute JavaScript $('#form-widgets-${field-name}')
+ ... .parent().parent().find('label')
+ ... .text('${field-name} size is ' + $('#form-widgets-${field-name} img').width() + 'x' + $('#form-widgets-${field-name} img').height());
Page Should Contain ${field-name} size is 232x233
-
-Open Cropping Editor For
- [Arguments] ${field-name}
- Click Link link=Cropping
+i choose field '${field-name}' in cropping editor
+ i click on the cropping tab
Click Link link=${field-name}
- Page Should Contain Image Cropping Editor
View
50 src/plone/app/imagecropping/tests/robot/test_imagecropping.robot
@@ -1,32 +1,30 @@
*** Settings ***
+Resource plone/app/robotframework/selenium.robot
+Resource plone/app/robotframework/keywords.robot
+Resource plone/app/imagecropping/tests/robot/keywords.robot
-Library Selenium2Library timeout=10 implicit_wait=0.5 run_on_failure=Capture Page Screenshot
+Library Remote ${PLONE_URL}/RobotRemote
+Variables plone/app/imagecropping/tests/variables.py
+Variables plone/app/testing/interfaces.py
-Resource keywords.robot
-
-Variables plone/app/testing/interfaces.py
-Variables plone/app/imagecropping/tests/variables.py
-
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
-
-*** Variables ***
-
-${PORT} = 55001
-${ZOPE_URL} = http://localhost:${PORT}
-${PLONE_URL} = ${ZOPE_URL}/plone
-${BROWSER} = Firefox
-
-${front-page} http://localhost:55001/plone/
-${test-folder} http://localhost:55001/plone/acceptance-test-folder
+Test Setup Open Test Browser
+Test Teardown Close All Browsers
*** Test Cases ***
-
-Test Image Cropping
- Log in as site owner
- Go to ${test-folder}
- Create Image Test-Image
- Open Cropping Editor
- Crop On Image Size preview 560 20
- Image Must Be Cropped
+Scenario: Crop plone default image type
+ Given i am logged in as a Contributor
+ When i create an image called 'test-image'
+ And i click on the cropping tab
+ And i crop the image size 'preview' to 560 x 20
+ Then image should be cropped
+
+Scenario: Crop custom contenttype containing two image fields
+ Given i am logged in as a Contributor
+ When i create a two-image-field containing type called 'test-two-image-fields'
+ And i click on the cropping tab
+ And i crop the image size 'preview' to 560 x 20
+ Then 'test-two-image-fields' image in field 'first_image' should be cropped
+ When i choose field 'second_image' in cropping editor
+ And i crop the image size 'preview' to 560 x 20
+ Then 'test-two-image-fields' image in field 'second_image' should be cropped
View
36 src/plone/app/imagecropping/tests/robot/test_imagecropping_for_dexterity_set_fields.robot
@@ -1,36 +0,0 @@
-*** Settings ***
-
-Library Selenium2Library timeout=10 implicit_wait=0.5 run_on_failure=Capture Page Screenshot
-
-Resource keywords.robot
-
-Variables plone/app/testing/interfaces.py
-Variables plone/app/imagecropping/tests/variables.py
-
-Suite Setup Suite Setup
-Suite Teardown Suite Teardown
-
-*** Variables ***
-
-${PORT} = 55001
-${ZOPE_URL} = http://localhost:${PORT}
-${PLONE_URL} = ${ZOPE_URL}/plone
-${BROWSER} = Firefox
-
-${front-page} http://localhost:55001/plone/
-${test-folder} http://localhost:55001/plone/acceptance-test-folder
-
-
-*** Test Cases ***
-
-Test Image Cropping
- Log in as site owner
- Go to ${test-folder}
- Create dexterity content type with two image fields Test-Two-Image-Fields
- Open Cropping Editor For first_image
- Crop On Image Size preview 560 20
- Open Cropping Editor For second_image
- Crop On Image Size preview 560 20
- Image Must Be Cropped For test-two-image-fields first_image
- Image Must Be Cropped For test-two-image-fields second_image
-
Please sign in to comment.
Something went wrong with that request. Please try again.