Merge lp:~senan/ubuntu-autopilot-tests/DiskUsageAnalyser into lp:ubuntu-autopilot-tests

Proposed by Prabhendu V Senan
Status: Superseded
Proposed branch: lp:~senan/ubuntu-autopilot-tests/DiskUsageAnalyser
Merge into: lp:ubuntu-autopilot-tests
Diff against target: 166 lines (+159/-0)
1 file modified
ubuntu_autopilot_tests/DiskUsageAnalyser/test_diskUsageAnalyser.py (+159/-0)
To merge this branch: bzr merge lp:~senan/ubuntu-autopilot-tests/DiskUsageAnalyser
Reviewer Review Type Date Requested Status
Dan Chapman  Pending
Review via email: mp+206604@code.launchpad.net

This proposal supersedes a proposal from 2014-01-26.

This proposal has been superseded by a proposal from 2014-02-21.

Description of the change

I think, I've fixed the 3 issues you mentioned in last review. for Ring chart and Tree map, I've used the GtkAccessible showing property to validate whether the ring chart and tree map is displayed or not..please review it and let me know your comments.

To post a comment you must log in.
Revision history for this message
Dan Chapman  (dpniel) wrote : Posted in a previous version of this proposal

First off this is a great start :-) Well Done. Its always the trickiest part learning what you can and can't do with autopilot.

So my first thoughts are (and keeping in mind the near release of autopilot 1.4),

1) the test window title failed on my box. Due to having a different locale where analyzer is actually analyser. So to make this work you would probably be better testing the title with something like Contains('Disk Usage'). Then we miss the strange locale issues.

Note that if you wanted the test to pass on any locale you could assertThat(title, NotEquals(None)) and then assertIsInstance(title, unicode). This will test that the title contains text (we don't know what the title text will be, but we can test the title is there and that its unicode.

2) the other 3 tests are very similar so you could probably break them up a little. My first point with this is you are finishing each test outside of the test function with the self.disk_usage_display_common() call. Ideally you should be finishing each test with asserts as the last lines inside your test function. This way you can see the intended end result of the test i.e "the treeviewmap and ringmap should display a 'x' directory/folder" try and do the setup type parts to get you to the point you need outside the test function and then come back once setup to test the thing you are actually testing

another thing when entering /home in the file chooser dialog you should use the provided function in the keyboard class 'focused_type' so for example once you have clicked the toggle button and the entry is visible you could use something like this

entry = self.app.select_single('GtkFileChooserEntry')
with self.keyboard.focused_type(entry) as kb:
    kb.type('/home')
    self.assertThat(entry.text, Equals('/home'))
    kb.press_and_release('Enter')

This will get the entries focus and type the text see http://unity.ubuntu.com/autopilot/api/input.html#autopilot.input.Keyboard.focused_type

There is also some changes needed to be made for 1.4 if you check this link about boolean properties are now represented correctly and not 1/0. http://unity.ubuntu.com/autopilot/porting/porting.html#gtk-tests-and-boolean-parameters

I'll leave it there for now and see how we fair once these changes are made.

Feel free to ping myself or balloons if your are getting stuck :-)

Revision history for this message
Dan Chapman  (dpniel) wrote : Posted in a previous version of this proposal

Senan hey,

So what i was trying to say in IRC is that you are repeating code in a few of your tests. So lets use the test_scan_local_folder for this example and you will be able to use it in the other test just as easy

lets start with this part of the test

def test_scan_local_folder(self):
    self.gear_menu_option_button = self.app.select_single(BuilderName='menu-button')
    self.pointing_device.move_to_object(self.gear_menu_option_button)
    self.pointing_device.click()
    self.create_scan_folder_menu_item = self.app.select_single('GtkModelMenuItem',action_name= 'win.scan-folder')
    self.pointing_device.move_to_object(self.create_scan_folder_menu_item)
    self.pointing_device.click()

you use this same process in two tests but selecting a different GtkModelMenuItem for each test, so this can be broken out into its own function and you pass in the name of the GtkModelMenuItem you need for each test

you should use more descriptive names than this, i'm just showing examples

def test_scan_local_folder(self):
    self.open_folder_dialog('win.scan-folder')
    # .. Rest of test ..

def open_folder_dialog(self, item_name):
    gear_menu_option_button = self.app.select_single(BuilderName='menu-button')
    self.pointing_device.click_object(self.gear_menu_option_button)
    #now select the passed in menu item
    create_scan_folder_menu_item = self.app.select_single('GtkModelMenuItem',action_name=item_name)
    self.pointing_device.click_object(create_scan_folder_menu_item)

so now for your tests you can reuse this and just pass in the action_name of the menu item
i.e
self.open_folder_dialog('win.scan-folder')
self.open_folder_dialog('win.scan-remote')

Thats an example of what i mean by breaking up the tests a bit and re-using code makes it easier to maintain.

Regarding my comments on finishing the tests inside the test function, currently on some of the tests you call self.disk_usage_display_common() as the last call of your test, this in effect takes us out of the test function and we have to go looking elswhere to see what the intent of the test function is trying to assert. Each test method should work like

def Test
    1) setup the test (this is the setup function which starts baobab)
    2) get the test into the required state for this test. ( so using functions outside the test function )
    3) once in the required state for the test, assert what we want to test. as the last part of the test function

take a look at the gedit test as an example the test are only testing one thing only then move on to the next test.

so as an example you could break tests up like

1) test we can open home folder ( but we do not check the folder is being displayed properly thats another test)
2) test that the tree map diplays the home folder
3) test trying to open a folder that doesn't exist.

Each test should not depend on any other test. So create functions of common code that you can use to get a test to its 'required state'

I hope this is of some help

Revision history for this message
Dan Chapman  (dpniel) wrote : Posted in a previous version of this proposal

Senan

so the test_window_title is still failing for me due to the locale issue with the spelling of analyser so i would just remove that and assert 'Disk Usage '.

Also when entering text you need explicitly make sure you get the text entry focus, by either clicking on it assert entry.is_focus = True and then type or you can use the focused_type context manager. e.g currenlty you have this

111 + self.create_toggle_button = self.app.select_single('GtkToggleButton',tooltip_text=u'Type a file name')
112 + self.pointing_device.move_to_object(self.create_toggle_button)
113 + self.pointing_device.click()
114 + self.keyboard.type(key_input)

Which once you have clicked the toggle button we do not actually know if the entry is now visable and has focus before typing. So after the clicking the toggle button you need to

1) assert entry.visible == True

2) either click on the entry and assert entry.is_focus == True before typing
or use the focused_type context manager (which i prefer) which looks something like

entry = self.app.select_single('GtkFileChooserEntry')
 with self.keyboard.focused_type(entry) as kb:
     kb.type(key_input)
     self.assertThat(entry.text, Equals(key_input)) (after typing assert it type correctly)
     kb.press_and_release('Enter')

3) test you have ended where you expected :-)

So anywhere in your tests you are entering text you need to do one of the above so we know the entry has focus if we can't get focus then we have a bug :-)

One last thing all boolean values your test that are using ints need to be changed for autopilot 1.4 i.e

self.assertThat(window.visible, Equals(1)) will become self.assertThat(window.visible, Equals(True)) and all 0 values become False. If you are on saucy install autopilot from the ppa:autopilot/ppa and you will get autopilot 1.4
We need to make our tests compliant with 1.4 as soon as possible.

THank you for iterating over these tests, your doing a great job and soon you will get into the swing of it, just hang in there :-)

Dan

Revision history for this message
Dan Chapman  (dpniel) wrote : Posted in a previous version of this proposal

Hey senan, i'm still looking into the problems we were having last night. I am waiting on a reply from someone who may no more so as soon as hear anything we will move onwards with this. Sorry about the delay, sometimes these little niggles need sorting first :-)

Hope you are well

Dan

Revision history for this message
Prabhendu V Senan (senan) wrote : Posted in a previous version of this proposal

Thanks Dan
On 22 Nov 2013 16:36, "Dan Chapman" <email address hidden> wrote:

> Hey senan, i'm still looking into the problems we were having last night.
> I am waiting on a reply from someone who may no more so as soon as hear
> anything we will move onwards with this. Sorry about the delay, sometimes
> these little niggles need sorting first :-)
>
> Hope you are well
>
> Dan
> --
>
> https://code.launchpad.net/~senan/ubuntu-autopilot-tests/DiskUsageAnalyser/+merge/193087
> You are the owner of lp:~senan/ubuntu-autopilot-tests/DiskUsageAnalyser.
>

Revision history for this message
Dan Chapman  (dpniel) wrote : Posted in a previous version of this proposal

Senan hey you left too soon, ok ive been having a play and added something ive been working on for a little while (some helpful emulators :-) ), ive adapted your branch slightly here https://code.launchpad.net/~dpniel/+junk/baobab and it uses emulators for selecting items in tree so feel free to branch it have a play and see what you can come up with, take a while to look through emulators.py and see whats happening :-)

Hope this helps in the mean time till we can figure out what the difference is between desktop and sandbox

Dan

Revision history for this message
Prabhendu V Senan (senan) wrote : Posted in a previous version of this proposal
Download full text (6.7 KiB)

Hi Dan,

I've made some changes to the code in order to address the
filechooserdialog treeview click issue. http://paste.ubuntu.com/6612284/ .
But I am sure its not the best way to resolve the issue. But I am still not
able to identify the treeview. Looking forward to your review comments.

On Tue, Oct 29, 2013 at 10:01 PM, Prabhendu V Senan <<email address hidden>
> wrote:

> Prabhendu V Senan has proposed merging
> lp:~senan/ubuntu-autopilot-tests/DiskUsageAnalyser into
> lp:ubuntu-autopilot-tests.
>
> Requested reviews:
> Ubuntu Testcase Admins (ubuntu-testcase)
>
> For more details, see:
>
> https://code.launchpad.net/~senan/ubuntu-autopilot-tests/DiskUsageAnalyser/+merge/193087
> --
>
> https://code.launchpad.net/~senan/ubuntu-autopilot-tests/DiskUsageAnalyser/+merge/193087
> You are the owner of lp:~senan/ubuntu-autopilot-tests/DiskUsageAnalyser.
>
> === added directory 'ubuntu_autopilot_tests/DiskUsageAnalyser'
> === added file 'ubuntu_autopilot_tests/DiskUsageAnalyser/__init__.py'
> === added file
> 'ubuntu_autopilot_tests/DiskUsageAnalyser/test_diskUsageAnalyser.py'
> --- ubuntu_autopilot_tests/DiskUsageAnalyser/test_diskUsageAnalyser.py
> 1970-01-01 00:00:00 +0000
> +++ ubuntu_autopilot_tests/DiskUsageAnalyser/test_diskUsageAnalyser.py
> 2013-10-29 16:26:36 +0000
> @@ -0,0 +1,95 @@
> +from autopilot.testcase import AutopilotTestCase
> +from autopilot.matchers import Eventually
> +from testtools.matchers import Equals, Contains, NotEquals
> +
> +from autopilot.input import Mouse, Pointer
> +
> +import os
> +from time import sleep
> +
> +class DiskUsageAnalyserTests(AutopilotTestCase):
> +
> + def setUp(self):
> + super(DiskUsageAnalyserTests,self).setUp()
> + self.app = self.launch_test_application('baobab')
> + self.mainWindowTitle = self.app.select_single('BaobabWindow')
> + self.pointing_device = Pointer(Mouse.create())
> +
> + def test_window_title(self):
> + # Verify the Disk Usage Analyzer application Title
> +
> self.assertThat(self.mainWindowTitle.title,Eventually(Contains('Disk Usage
> Analyzer')))
> +
> + def test_scan_local_folder(self):
> + self.gear_menu_option_button =
> self.app.select_single(BuilderName='menu-button')
> +
> self.pointing_device.move_to_object(self.gear_menu_option_button)
> + self.pointing_device.click()
> + self.create_scan_folder_menu_item =
> self.app.select_single('GtkModelMenuItem',action_name= 'win.scan-folder')
> +
> self.pointing_device.move_to_object(self.create_scan_folder_menu_item)
> + self.pointing_device.click()
> + self.assertThat(lambda:
> self.app.select_single('GtkFileChooserDialog').visible,Eventually(Equals(1)))
> + dialog = self.app.select_single('GtkFileChooserDialog')
> + self.assertThat(dialog.title,Eventually(Equals('Select
> Folder')))
> + tree_view = dialog.select_many('GtkTreeView')[0]
> + self.pointing_device.click_object(tree_view)
> +
> + self.create_toggle_button =
> self.app.select_single('GtkToggleButton',tooltip_text=u'Type a file name')
> +
> self.po...

Read more...

Revision history for this message
Dan Chapman  (dpniel) wrote : Posted in a previous version of this proposal

This is really making progress now, nice work. THere is just a couple more things that need tweaking,

1) The test script formatting is a little whacky, it looks like you have been using 8 space tab characters for part of it, ideally you should set this to 4 spaces.

2) When entering /home/ in the file chooser dialog it doesn't seem to close beacause of the autocompletion box being open, you need to make sure after typing either press 'Delete' so the autocompletion box closes or double click the _open button. It would also be good to assert that the PathBar in the dialog is in the /Home directory.

3) With regards to checking the ring and bar charts igf you look in vis their visible property is always set to true even when not visible, so asserting it's visible isn't gaining us anything. We should try and find another way to assert they are visible

If you can make these changes then i think we are nearly there :-) Nice One!

review: Needs Fixing
Revision history for this message
Prabhendu V Senan (senan) wrote : Posted in a previous version of this proposal

> This is really making progress now, nice work. THere is just a couple more
> things that need tweaking,

Thank you very much for the review :)
>
> 1) The test script formatting is a little whacky, it looks like you have been
> using 8 space tab characters for part of it, ideally you should set this to 4
> spaces.

I've fixed the spacing issue
>
> 2) When entering /home/ in the file chooser dialog it doesn't seem to close
> beacause of the autocompletion box being open, you need to make sure after
> typing either press 'Delete' so the autocompletion box closes or double click
> the _open button. It would also be good to assert that the PathBar in the
> dialog is in the /Home directory.

I've already implemented the code for removing auto-completion

editBox = self.app.select_single('GtkFileChooserEntry')
  #self.keyboard.focused_type(editBox)
  self.assertThat(editBox.is_focus,Equals(True))
  self.keyboard.type(key_input)
  sleep(2)
  self.keyboard.press_and_release('Delete')
  self.assertThat(editBox.text,Equals(key_input))

I am not sure why the auto-completion box is still showing even after this.. can you please check that. Also I didnt understand assert /Home in pathbar.PathBar in filechooserDlg or after clicking _open button
>
> 3) With regards to checking the ring and bar charts igf you look in vis their
> visible property is always set to true even when not visible, so asserting
> it's visible isn't gaining us anything. We should try and find another way to
> assert they are visible

I couldn't find any other propery to validate in this case..:( .. need your help
>
> If you can make these changes then i think we are nearly there :-) Nice One!

Revision history for this message
Dan Chapman  (dpniel) wrote : Posted in a previous version of this proposal

Senan
On 05/02/14 16:41, Prabhendu V Senan wrote:
>>
>>
>> I've already implemented the code for removing auto-completion
>>
>> editBox = self.app.select_single('GtkFileChooserEntry')
>> #self.keyboard.focused_type(editBox)
>> self.assertThat(editBox.is_focus,Equals(True))
>> self.keyboard.type(key_input)
>> sleep(2)
>> self.keyboard.press_and_release('Delete')
>> self.assertThat(editBox.text,Equals(key_input))
>>
>> I am not sure why the auto-completion box is still showing even after this.. can you please check that. Also I didnt understand assert /Home in pathbar.PathBar in filechooserDlg or after clicking _open button
This can be simple resolved by removing the trailing / so '/home/'
becomes '/home'. For the path bar it would be ideal to assert we are in
the required directory either by the pathbars label or stock icon
properties to determin we are in the correct place before clicking open
>> 3) With regards to checking the ring and bar charts igf you look in vis their
>> visible property is always set to true even when not visible, so asserting
>> it's visible isn't gaining us anything. We should try and find another way to
>> assert they are visible
> I couldn't find any other propery to validate in this case..:( .. need your help
I will need to investigate this further as it does seem quite tricky

71. By senan<email address hidden>

used index instead of menu names. fixed remote folder dialog

72. By senan<email address hidden>

removed sleep from test

73. By senan<email address hidden>

broken asserions into simple ones

74. By senan<email address hidden>

added bug number to the file

75. By senan<email address hidden>

renamed file

76. By senan<email address hidden>

added renamed file

77. By senan<email address hidden>

renamed file and folder for consistancy

78. By senan<email address hidden>

Formatted the code

79. By senan<email address hidden>

Formatted Code

80. By senan<email address hidden>

added mock

81. By senan<email address hidden>

added mock

82. By senan<email address hidden>

Added mock to create fake home directory

83. By senan<email address hidden>

added mock py2 py3 compatibility

84. By senan<email address hidden>

fixed scan_remote_folder input field issue

85. By senan<email address hidden>

added comments

86. By senan<email address hidden>

added comment for gear menu deselection

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '__init__.py'
2=== added directory 'ubuntu_autopilot_tests/DiskUsageAnalyser'
3=== added file 'ubuntu_autopilot_tests/DiskUsageAnalyser/__init__.py'
4=== added file 'ubuntu_autopilot_tests/DiskUsageAnalyser/test_diskUsageAnalyser.py'
5--- ubuntu_autopilot_tests/DiskUsageAnalyser/test_diskUsageAnalyser.py 1970-01-01 00:00:00 +0000
6+++ ubuntu_autopilot_tests/DiskUsageAnalyser/test_diskUsageAnalyser.py 2014-02-21 17:28:01 +0000
7@@ -0,0 +1,159 @@
8+from autopilot.testcase import AutopilotTestCase
9+from autopilot.matchers import Eventually
10+from testtools.matchers import Equals, Contains, NotEquals
11+from autopilot.introspection import get_proxy_object_for_existing_process
12+from autopilot.input import Mouse, Pointer
13+import os
14+from time import sleep
15+import subprocess
16+import locale
17+
18+class DiskUsageAnalyzerTests(AutopilotTestCase):
19+
20+ def setUp(self):
21+ super(DiskUsageAnalyzerTests,self).setUp()
22+ self.app = self.launch_test_application('baobab')
23+ self.mainWindowTitle = self.app.select_single('BaobabWindow')
24+ self.pointing_device = Pointer(Mouse.create())
25+ self.scan_folder_index = 0 #u'Scan Folder\u2026'
26+ self.scan_remote_folder_index = 1 #u'Scan Remote Folder\u2026'
27+
28+ def test_window_title(self):
29+ # Verify the Disk Usage Analyzer application Title
30+ self.assertThat(self.mainWindowTitle.title,Eventually(Contains('Disk Usage')))
31+
32+ def test_scan_local_folder(self):
33+ self.open_scan_folder_dialog(self.scan_folder_index)
34+ self.assertThat(lambda: self.app.select_single('GtkFileChooserDialog').visible,Eventually(Equals(True)))
35+ self.open_file_chooser_dialog('/home')
36+ self.assertThat(lambda:self.app.select_single('GdHeaderBar',BuilderName='result-header-bar').title,Eventually(Contains('home')))
37+
38+ def test_scan_remote_folder(self):
39+ #Scan remote folder--check only the UI components
40+ self.open_scan_folder_dialog(self.scan_remote_folder_index)
41+ self.pointing_device.move_to_object(self.gear_menu_option_button)
42+ self.pointing_device.click()
43+ sleep(2)
44+ encoding = locale.getdefaultlocale()[1] #To resolve Type str doesn't support the buffer API
45+ cmd_output = subprocess.Popen("ps -ef | pgrep nautilus-connect*",stdout=subprocess.PIPE, shell=True)
46+ self.connect_server_dlg_pid,error = cmd_output.communicate()
47+ self.connect_server_dlg_pid = int(self.connect_server_dlg_pid.decode(encoding).rstrip('\n'))
48+ self.assertNotEqual(self.connect_server_dlg_pid,None)
49+ self.connect_server_dlg_proxy_object = get_proxy_object_for_existing_process(pid=self.connect_server_dlg_pid)
50+ input_server_name = self.connect_server_dlg_proxy_object.select_single('GtkEntry')
51+ with self.keyboard.focused_type(input_server_name) as kb:
52+ self.assertThat(input_server_name.is_focus,Equals(True))
53+ kb.type('smb://foo.example.org')
54+ kb.press_and_release('Delete')
55+ self.assertThat(input_server_name.text,Equals('smb://foo.example.org'))
56+ self.btn_connect = self.connect_server_dlg_proxy_object.select_single('GtkButton',label='C_onnect')
57+ self.btn_cancel = self.connect_server_dlg_proxy_object.select_single('GtkButton',label='_Cancel')
58+ self.assertThat(self.btn_connect.sensitive,Equals(True))
59+ self.assertThat(self.btn_cancel.sensitive,Equals(True))
60+ self.pointing_device.move_to_object(self.btn_cancel)
61+ self.pointing_device.click()
62+
63+ def test_home_list(self):
64+ #scan home folder listed in the applocations start page
65+ self.create_button_scan_home_folder = self.app.select_single('GtkLabel',label=u'<b>Home folder</b>')
66+ self.pointing_device.move_to_object(self.create_button_scan_home_folder)
67+ self.pointing_device.click()
68+ self.assertThat(lambda: self.app.select_single('GtkSpinner',BuilderName='spinner').sensitive,Eventually(Equals(True)))
69+ self.show_tree_map()
70+ self.assertThat(lambda: self.app.select_single('BaobabTreemap',BuilderName='treemap-chart').visible,Eventually(Equals(True)))
71+ self.show_ring_chart()
72+ self.assertThat(lambda: self.app.select_single('BaobabRingschart',BuilderName='rings-chart').visible,Eventually(Equals(True)))
73+
74+ def test_scan_folder_tree_map(self):
75+ self.open_scan_folder_dialog(self.scan_folder_index)
76+ self.assertThat(lambda: self.app.select_single('GtkFileChooserDialog').visible,Eventually(Equals(True)))
77+ self.open_file_chooser_dialog('/home')
78+ self.assertThat(lambda:self.app.select_single('GdHeaderBar',BuilderName='result-header-bar').title,Eventually(Contains('home')))
79+ self.show_tree_map()
80+ self.assertThat(lambda: self.app.select_single('BaobabTreemap',BuilderName='treemap-chart').visible,Eventually(Equals(True)))
81+
82+ def test_scan_folder_ring_chart(self):
83+ self.open_scan_folder_dialog(self.scan_folder_index)
84+ self.assertThat(lambda: self.app.select_single('GtkFileChooserDialog').visible,Eventually(Equals(1)))
85+ self.open_file_chooser_dialog('/home')
86+ self.assertThat(lambda:self.app.select_single('GdHeaderBar',BuilderName='result-header-bar').title,Eventually(Contains('home')))
87+ self.show_ring_chart()
88+ self.assertThat(lambda: self.app.select_single('BaobabRingschart',BuilderName='rings-chart').visible,Eventually(Equals(True)))
89+
90+ def show_tree_map(self):
91+ #Toggle treemap and ring chart
92+ self.assertThat(lambda: self.app.select_single('GtkSpinner',BuilderName='spinner').sensitive,Eventually(Equals(True)))
93+ self.assertThat(lambda: self.app.select_single('GtkRadioButtonAccessible',accessible_description='Treemap Chart').showing,Eventually(Equals(True)))
94+ self.tree_map_button = self.app.select_single('GtkRadioButton',BuilderName='treemap-button')
95+ self.assertThat(self.tree_map_button.sensitive,Eventually(Equals(True)))
96+ sleep(1)
97+ self.pointing_device.move_to_object(self.tree_map_button)
98+ self.pointing_device.click()
99+
100+ def show_ring_chart(self):
101+ self.assertThat(lambda: self.app.select_single('GtkSpinner',BuilderName='spinner').sensitive,Eventually(Equals(True)))
102+ self.assertThat(lambda: self.app.select_single('GtkRadioButtonAccessible',accessible_description='Rings Chart').showing,Eventually(Equals(True)))
103+ self.ring_button = self.app.select_single('GtkRadioButton',BuilderName='rings-button')
104+ self.assertThat(self.ring_button.sensitive,Eventually(Equals(True)))
105+ sleep(1)
106+ self.pointing_device.move_to_object(self.ring_button)
107+ self.pointing_device.click()
108+
109+ def open_scan_folder_dialog(self,menu_item_index):
110+ self.gear_menu_option_button = self.app.select_single(BuilderName='menu-button')
111+ self.pointing_device.move_to_object(self.gear_menu_option_button)
112+ self.pointing_device.click()
113+ sleep(2)
114+ window = self.app.select_many('GtkWindowAccessible')[1]
115+ #TODO
116+ #Following code is not working in autopilot3 and as a workaround used select_many for accessing menu item
117+ #self.create_scan_folder_sub_menu_item = window.select_single('GtkCheckMenuItemAccessible', accessible_name=menu_item_name)
118+ self.create_scan_folder_sub_menu_item = self.app.select_many('GtkCheckMenuItemAccessible')[menu_item_index]
119+ self.assertThat(self.create_scan_folder_sub_menu_item, NotEquals(None))
120+ self.pointing_device.move_to_object(self.create_scan_folder_sub_menu_item)
121+ self.pointing_device.click()
122+
123+ def open_file_chooser_dialog(self,key_input):
124+ dialog = self.app.select_single('GtkFileChooserDialog')
125+ self.assertThat(dialog.title,Eventually(Equals('Select Folder')))
126+ places_sidebar = self.app.select_single('GtkPlacesSidebar',BuilderName=u'places_sidebar')
127+ tree_view = places_sidebar.select_single('GtkTreeView')
128+ tree_item = self.get_tree_item(tree_view,'Home')
129+ self.pointing_device.move_to_object(tree_item)
130+ self.pointing_device.click_object(tree_item)
131+ self.create_toggle_button = self.app.select_single('GtkToggleButton',tooltip_text=u'Type a file name')
132+
133+ if not self.create_toggle_button.active:
134+ self.pointing_device.move_to_object(self.create_toggle_button)
135+ self.pointing_device.click()
136+ editBox = self.app.select_single('GtkFileChooserEntry')
137+ #self.keyboard.focused_type(editBox)
138+ self.assertThat(editBox.is_focus,Equals(True))
139+ self.keyboard.type(key_input)
140+ sleep(2)
141+ self.keyboard.press_and_release('Delete')
142+ self.assertThat(editBox.text,Equals(key_input))
143+ path_bar = dialog.select_single('GtkPathBar',BuilderName='browse_path_bar')
144+ path_bar_home_label = path_bar.select_many('GtkLabel')[2]
145+ self.assertThat(path_bar_home_label.label,Equals(key_input.lstrip('/')))
146+ #Open the scan directory
147+ self.open_scan_dir = self.app.select_single('GtkLabel',label='_Open')
148+ self.pointing_device.move_to_object(self.open_scan_dir)
149+ self.pointing_device.click()
150+
151+ def get_tree_item(self, treeview_object, item_label):
152+ """ Gets an item from a gtktreeview
153+ param treeview_object: a selected GtkTreeView object
154+ param item_label: Visual label value of the tree item i.e 'Documents'
155+ returns treeview item object"""
156+ #get all accessible treeviews
157+ accessible_treeviews = self.app.select_many('GtkTreeViewAccessible')
158+ # find the one that has the same globalRect as treeview_object
159+ for treeview_accessible in accessible_treeviews:
160+ if treeview_accessible.globalRect == treeview_object.globalRect:
161+ #select our item from here
162+ tree_item = treeview_accessible.select_many('GtkTextCellAccessible',accessible_name=item_label)
163+ return tree_item[1]
164+
165+
166+

Subscribers

People subscribed via source and target branches