[pitivi] dogtail tests: Merge the helper functions into one file
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] dogtail tests: Merge the helper functions into one file
- Date: Wed, 25 Jul 2012 11:56:02 +0000 (UTC)
commit ba798c785aee616b445ca094307eececf0225ada
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date: Fri Jul 20 20:20:57 2012 -0400
dogtail tests: Merge the helper functions into one file
tests/dogtail_scripts/helper_functions.py | 152 +++++++++++++++++--
tests/dogtail_scripts/test_clipproperties.py | 2 +-
.../dogtail_scripts/test_dialogs_clipmediaprops.py | 2 +-
tests/dogtail_scripts/test_dialogs_prefs.py | 2 +-
.../dogtail_scripts/test_dialogs_startupwizard.py | 2 +-
tests/dogtail_scripts/test_effects.py | 11 +-
tests/dogtail_scripts/test_help_func.py | 125 ----------------
tests/dogtail_scripts/test_medialibrary.py | 2 +-
tests/dogtail_scripts/test_project.py | 2 +-
tests/dogtail_scripts/test_timeline.py | 17 +--
10 files changed, 155 insertions(+), 162 deletions(-)
---
diff --git a/tests/dogtail_scripts/helper_functions.py b/tests/dogtail_scripts/helper_functions.py
index 0a30ad9..e3f61f1 100644
--- a/tests/dogtail_scripts/helper_functions.py
+++ b/tests/dogtail_scripts/helper_functions.py
@@ -1,25 +1,145 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import unittest
import os
from dogtail.predicate import GenericPredicate
+from test_base import BaseDogTail
import dogtail.rawinput
from time import sleep
+from pyatspi import Registry as registry
+from pyatspi import (KEY_SYM, KEY_PRESS, KEY_PRESSRELEASE, KEY_RELEASE)
-def improved_drag(fromcord, tocord, middle=[], absolute=True, moveAround=True):
- dogtail.rawinput.press(fromcord[0], fromcord[1])
- if moveAround:
- dogtail.rawinput.relativeMotion(5, 5)
- dogtail.rawinput.relativeMotion(-5, -5)
- if absolute:
- fun = dogtail.rawinput.absoluteMotion
- else:
- fun = dogtail.rawinput.relativeMotion
- for mid in middle:
- fun(mid[0], mid[1])
+class HelpFunc(BaseDogTail):
+ def saveProject(self, url=None, saveAs=True):
+ self.menubar.menu("Project").click()
+ if saveAs:
+ #FIXME: cant get working with searching for Save Asâ
+ self.menubar.menu("Project").children[4].click()
+ saveas = self.pitivi.child(roleName='dialog')
+ saveas.child(roleName='text').text = url
+ #Click the Save button.
+ saveas.button('Save').click()
+ #Save for deleting afterwards
+ self.unlink.append(url)
+ else:
+ #Just save
+ self.menubar.menu("Project").menuItem("Save").click()
+
+ def loadProject(self, url, save=False):
+ self.menubar.menu("Project").click()
+ self.menubar.menu("Project").children[2].click()
+ load = self.pitivi.child(roleName='dialog')
+ load.child(name="Type a file name", roleName="toggle button").click()
+ load.child(roleName='text').text = url
+ load.button('Open').click()
+ try:
+ if save:
+ load.child(name="Close without saving", roleName="push button")
+ except:
+ return
+
+ def search_by_text(self, text, parent, name=None, roleName=None):
+ children = parent.findChildren(GenericPredicate(roleName=roleName,
+ name=name))
+ searched = None
+ for child in children:
+ if child.text == text:
+ searched = child
+ return searched
+
+ def insert_clip(self, icon, n=1):
+ icon.select()
+ lib = self.menubar.menu("Library")
+ insert = lib.child("Insert at End of Timeline")
+ for i in range(n):
+ sleep(0.3)
+ lib.click()
+ sleep(0.1)
+ insert.click()
+ icon.deselect()
+
+ def import_media(self, filename="1sec_simpsons_trailer.mp4"):
+ #Just try search for object without retries
+ dogtail.rawinput.pressKey("Esc")
+ self.pitivi.child(name="Import Files...",
+ roleName="push button").click()
+ add = self.pitivi.child(roleName='dialog')
+ textf = add.findChildren(GenericPredicate(roleName="text"))
+ if len(textf) == 0:
+ add.child(name="Type a file name", roleName="toggle button").click()
+ filepath = os.path.realpath(__file__).split("dogtail_scripts/")[0]
+ filepath += "samples/" + filename
+ add.child(roleName='text').text = filepath
+ add.button('Add').click()
+ libtab = self.pitivi.tab("Media Library")
+ for i in range(5):
+ icons = libtab.findChildren(GenericPredicate(roleName="icon"))
+ sample = None
+ for icon in icons:
+ if icon.text == filename:
+ sample = icon
+ if sample is not None:
+ break
+ sleep(0.5)
+ self.assertIsNotNone(sample)
+ return sample
+
+ def import_media_multiple(self, files):
+ dogtail.rawinput.pressKey("Esc")
+ self.pitivi.child(name="Import Files...",
+ roleName="push button").click()
+ add = self.pitivi.child(roleName='dialog')
+ textf = add.findChildren(GenericPredicate(roleName="text"))
+ if len(textf) == 0:
+ add.child(name="Type a file name", roleName="toggle button").click()
+ filepath = os.path.realpath(__file__).split("dogtail_scripts/")[0]
+ filepath += "samples/"
+ add.child(roleName='text').click()
+ add.child(roleName='text').text = filepath
+ dogtail.rawinput.pressKey("Enter")
+ #Now select them
+ code = dogtail.rawinput.keyNameToKeyCode("Control_L")
+ registry.generateKeyboardEvent(code, None, KEY_PRESS)
+ for f in files:
+ sleep(1)
+ add.child(name=f).click()
+ registry.generateKeyboardEvent(code, None, KEY_RELEASE)
+ add.button('Add').click()
+ libtab = self.pitivi.tab("Media Library")
+ samples = []
+ for i in range(5):
+ icons = libtab.findChildren(GenericPredicate(roleName="icon"))
+ for icon in icons:
+ for f in files:
+ if icon.text == f:
+ samples.append(icon)
+ files.remove(f)
+ if len(files) == 0:
+ break
+ sleep(0.5)
+ return samples
+
+ def get_timeline(self):
+ #TODO: found better way to identify
+ return self.pitivi.children[0].children[0].children[2].children[1].children[3]
+
+ def improved_drag(self, from_coords, to_coords, middle=[], absolute=True, moveAround=True):
+ dogtail.rawinput.press(from_coords[0], from_coords[1])
+ if moveAround:
+ dogtail.rawinput.relativeMotion(5, 5)
+ dogtail.rawinput.relativeMotion(-5, -5)
+ if absolute:
+ fun = dogtail.rawinput.absoluteMotion
+ else:
+ fun = dogtail.rawinput.relativeMotion
+ for mid in middle:
+ fun(mid[0], mid[1])
+ if moveAround:
+ dogtail.rawinput.relativeMotion(5, 5)
+ dogtail.rawinput.relativeMotion(-5, -5)
+ dogtail.rawinput.absoluteMotion(to_coords[0], to_coords[1])
if moveAround:
dogtail.rawinput.relativeMotion(5, 5)
dogtail.rawinput.relativeMotion(-5, -5)
- dogtail.rawinput.absoluteMotion(tocord[0], tocord[1])
- if moveAround:
- dogtail.rawinput.relativeMotion(5, 5)
- dogtail.rawinput.relativeMotion(-5, -5)
- dogtail.rawinput.release(tocord[0], tocord[1])
+ dogtail.rawinput.release(to_coords[0], to_coords[1])
diff --git a/tests/dogtail_scripts/test_clipproperties.py b/tests/dogtail_scripts/test_clipproperties.py
index 22233e6..1e18dd3 100644
--- a/tests/dogtail_scripts/test_clipproperties.py
+++ b/tests/dogtail_scripts/test_clipproperties.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
+from helper_functions import HelpFunc
from dogtail.predicate import GenericPredicate
import dogtail.rawinput
from time import sleep
diff --git a/tests/dogtail_scripts/test_dialogs_clipmediaprops.py b/tests/dogtail_scripts/test_dialogs_clipmediaprops.py
index 1853b47..a0f4e2c 100644
--- a/tests/dogtail_scripts/test_dialogs_clipmediaprops.py
+++ b/tests/dogtail_scripts/test_dialogs_clipmediaprops.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
+from helper_functions import HelpFunc
from dogtail.tree import SearchError
from dogtail.predicate import GenericPredicate, IsATextEntryNamed
diff --git a/tests/dogtail_scripts/test_dialogs_prefs.py b/tests/dogtail_scripts/test_dialogs_prefs.py
index 9181443..54ec49c 100644
--- a/tests/dogtail_scripts/test_dialogs_prefs.py
+++ b/tests/dogtail_scripts/test_dialogs_prefs.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
+from helper_functions import HelpFunc
from dogtail.tree import SearchError
import dogtail.rawinput
diff --git a/tests/dogtail_scripts/test_dialogs_startupwizard.py b/tests/dogtail_scripts/test_dialogs_startupwizard.py
index 7ba0545..d96ba12 100644
--- a/tests/dogtail_scripts/test_dialogs_startupwizard.py
+++ b/tests/dogtail_scripts/test_dialogs_startupwizard.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
+from helper_functions import HelpFunc
from time import time, sleep
diff --git a/tests/dogtail_scripts/test_effects.py b/tests/dogtail_scripts/test_effects.py
index aa88b60..76cf372 100644
--- a/tests/dogtail_scripts/test_effects.py
+++ b/tests/dogtail_scripts/test_effects.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
-from helper_functions import improved_drag
+from helper_functions import HelpFunc
import dogtail.rawinput
@@ -51,23 +50,23 @@ class EffectLibraryTest(HelpFunc):
icon = self.search_by_text("Agingtv ", tab, roleName="icon")
#Drag video effect on the clip
- improved_drag(center(icon), clippos)
+ self.improved_drag(center(icon), clippos)
self.assertEqual(len(table.children), 6)
#Drag video effect to the table
icon = self.search_by_text("3Dflippo", tab, roleName="icon")
- improved_drag(center(icon), center(table))
+ self.improved_drag(center(icon), center(table))
self.assertEqual(len(table.children), 9)
#Drag audio effect on the clip
tab.child(name="Video effects", roleName="combo box").click()
tab.menuItem("Audio effects").click()
effect = tab.child(name="Amplifier")
- improved_drag(center(effect), clippos)
+ self.improved_drag(center(effect), clippos)
self.assertEqual(len(table.children), 12)
#Drag audio effect on the table
effect = tab.child(name="Audiokaraoke")
- improved_drag(center(effect), center(table))
+ self.improved_drag(center(effect), center(table))
self.assertEqual(len(table.children), 15)
def test_change_effect_settings(self):
diff --git a/tests/dogtail_scripts/test_medialibrary.py b/tests/dogtail_scripts/test_medialibrary.py
index dd93b4c..1a12fa7 100644
--- a/tests/dogtail_scripts/test_medialibrary.py
+++ b/tests/dogtail_scripts/test_medialibrary.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
+from helper_functions import HelpFunc
class MediaLibraryTest(HelpFunc):
diff --git a/tests/dogtail_scripts/test_project.py b/tests/dogtail_scripts/test_project.py
index 94c4ade..33960f7 100644
--- a/tests/dogtail_scripts/test_project.py
+++ b/tests/dogtail_scripts/test_project.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
+from helper_functions import HelpFunc
from dogtail.predicate import IsATextEntryNamed, GenericPredicate
from time import time, sleep
import os
diff --git a/tests/dogtail_scripts/test_timeline.py b/tests/dogtail_scripts/test_timeline.py
index 0053a4a..96151cf 100644
--- a/tests/dogtail_scripts/test_timeline.py
+++ b/tests/dogtail_scripts/test_timeline.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-from test_help_func import HelpFunc
+from helper_functions import HelpFunc
from dogtail.predicate import GenericPredicate
-from helper_functions import improved_drag
import dogtail.rawinput
from time import sleep
from pyatspi import Registry as registry
@@ -49,7 +48,7 @@ class TimelineTest(HelpFunc):
timeline = self.get_timeline()
center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)
- improved_drag(center(sample), center(timeline))
+ self.improved_drag(center(sample), center(timeline))
self.nextb.click()
self.assertNotEqual(seektime.text, "0:00:00.000")
@@ -66,12 +65,12 @@ class TimelineTest(HelpFunc):
endpos.append((timeline.position[0] + timeline.size[0] - 30, timeline.position[1] + 80))
for i in range(20):
if (i % 4 == 0):
- #Drag to center, next layer, out, and then back in
- improved_drag(center(sample), endpos[i % 3], middle=[center(timeline), endpos[(i + 1) % 2], center(sample)])
+ # Drag to center, next layer, out, and then back in
+ self.improved_drag(center(sample), endpos[i % 3], middle=[center(timeline), endpos[(i + 1) % 2], center(sample)])
else:
- #Simple drag
- improved_drag(center(sample), endpos[i % 3])
- #Give time to insert object
+ # Simple drag
+ self.improved_drag(center(sample), endpos[i % 3])
+ # Give time to insert object
sleep(0.5)
self.nextb.click()
self.assertNotEqual(oldseek, seektime.text)
@@ -190,7 +189,7 @@ class TimelineTest(HelpFunc):
center = lambda obj: (obj.position[0] + obj.size[0] / 2, obj.position[1] + obj.size[1] / 2)
table = conftab.child(roleName="table")
icon = self.search_by_text("Agingtv ", tab, roleName="icon")
- improved_drag(center(icon), center(table))
+ self.improved_drag(center(icon), center(table))
self.nextb.click()
seekbefore = seektime.text
#Try riple and roll
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]