Merge lp:~aacid/unity-2d/unity-2d_test_common_definitions into lp:unity-2d

Proposed by Albert Astals Cid on 2012-01-26
Status: Merged
Approved by: Gerry Boland on 2012-01-26
Approved revision: 871
Merged at revision: 869
Proposed branch: lp:~aacid/unity-2d/unity-2d_test_common_definitions
Merge into: lp:unity-2d
Diff against target: 265 lines (+32/-29)
5 files modified
tests/launcher/always_visible_tests.rb (+2/-3)
tests/launcher/autohide_show_tests.rb (+24/-25)
tests/launcher/launcher_sizing.rb (+0/-1)
tests/misc/lib/definitions.rb (+3/-0)
tests/run-tests.rb (+3/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d_test_common_definitions
Reviewer Review Type Date Requested Status
Gerry Boland 2012-01-26 Approve on 2012-01-26
Review via email: mp+90251@code.launchpad.net

Description of the Change

[test] Add a file with the common definitions of variables

To post a comment you must log in.
Gerry Boland (gerboland) wrote :

This is great, thank you.

Suggestions:
1. Would it not make sense to include the definitions.rb file in run-tests.rb? I don't see it causing problems
2. If you disagree with 1, then I want to point out the following:

In Ruby1.8, require is pretty stupid. Whenever you require a file, it keeps a list of the files you 'require' to prevent you requiring the same file twice. Great! But the way it does this is naive. In your case it saves $PWD + '../misc/definitions.rb' -> '/home/you/dev/unity-2d-shell/tests/launcher/../misc/definitions.rb'

Now for a test in the tests/places directory, if you do the same require statement, require considers '/home/you/dev/unity-2d-shell/tests/places/../misc/definitions.rb' which doesn't match anything in the list, so the file gets required again, and you get constant redefined warnings.

Ruby1.9 fixes this. But we're stuck with 1.8 for now (Testability has't been ported to 1.9).

Solution: require $library_path + '/misc/definitions.rb'

review: Needs Fixing
Albert Astals Cid (aacid) wrote :

Makes sense, included in run-tests.rb

871. By Albert Astals Cid on 2012-01-26

Include definitions.rb from run-tests.rb as suggested by Gerry

Gerry Boland (gerboland) wrote :

Beautiful, merging!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/launcher/always_visible_tests.rb'
2--- tests/launcher/always_visible_tests.rb 2012-01-25 16:09:01 +0000
3+++ tests/launcher/always_visible_tests.rb 2012-01-26 12:58:23 +0000
4@@ -30,7 +30,6 @@
5
6 ############################# Test Suite #############################
7 context "Launcher Always Visible Behaviour Tests" do
8- WIDTH = 65 #launcher bar width
9 hide_mode = 0
10
11 # Run once at the beginning of this test suite
12@@ -88,9 +87,9 @@
13 # * None
14 test "Launcher pushes windows" do
15 $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Launcher hide-mode 2'
16- xid = TmpWindow.open_window_at(WIDTH / 2, 10)
17+ xid = TmpWindow.open_window_at(LAUNCHER_WIDTH / 2, 10)
18 $SUT.execute_shell_command 'gsettings set com.canonical.Unity2d.Launcher hide-mode 0'
19- verify_equal( WIDTH + 1, TIMEOUT, 'Window was not pushed by setting Launcher to always visible' ) {
20+ verify_equal( LAUNCHER_WIDTH + 1, TIMEOUT, 'Window was not pushed by setting Launcher to always visible' ) {
21 xid.position[0]
22 }
23 xid.close!
24
25=== modified file 'tests/launcher/autohide_show_tests.rb'
26--- tests/launcher/autohide_show_tests.rb 2012-01-24 17:06:04 +0000
27+++ tests/launcher/autohide_show_tests.rb 2012-01-26 12:58:23 +0000
28@@ -30,7 +30,6 @@
29
30 ############################# Test Suite #############################
31 context "Launcher Autohide and Show Tests" do
32- WIDTH = 65 #launcher bar width
33 launcher_favorites = ""
34
35 # Run once at the beginning of this test suite
36@@ -79,7 +78,7 @@
37 # Pre-conditions
38 # * Desktop with no running applications
39 # Test steps
40- # * Verify Launcher is #{WIDTH} pixels wide
41+ # * Verify Launcher is #{LAUNCHER_WIDTH} pixels wide
42 # * Verify Launcher showing
43 # Post-conditions
44 # * None
45@@ -87,7 +86,7 @@
46 # * None
47 test "Position with Empty Desktop" do
48 # check width before proceeding
49- verify_equal( WIDTH, TIMEOUT, "Launcher is not #{WIDTH} pixels wide on screen!" ) {
50+ verify_equal( LAUNCHER_WIDTH, TIMEOUT, "Launcher is not #{LAUNCHER_WIDTH} pixels wide on screen!" ) {
51 @app.Unity2dPanel()['width'].to_i
52 }
53
54@@ -132,7 +131,7 @@
55 test "Position with Window in the way" do
56 # Open Terminal with position 40x100
57 xid = TmpWindow.open_window_at(40,100)
58- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible when window in the way, should be hidden' ) {
59+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible when window in the way, should be hidden' ) {
60 @app.Unity2dPanel()['x_absolute'].to_i
61 }
62 xid.close!
63@@ -161,12 +160,12 @@
64 @app.Unity2dPanel()['x_absolute'].to_i
65 }
66
67- xid.move(WIDTH-1,100)
68- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible when window in the way, should be hidden' ) {
69+ xid.move(LAUNCHER_WIDTH-1,100)
70+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible when window in the way, should be hidden' ) {
71 @app.Unity2dPanel()['x_absolute'].to_i
72 }
73
74- xid.move(WIDTH,100)
75+ xid.move(LAUNCHER_WIDTH,100)
76 verify_equal( 0, TIMEOUT, 'Launcher hiding when window not in the way, should be visible' ) {
77 @app.Unity2dPanel()['x_absolute'].to_i
78 }
79@@ -193,30 +192,30 @@
80 # * None
81 test "Reveal hidden Launcher with mouse" do
82 xid = TmpWindow.open_window_at(10,100)
83- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
84+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
85 @app.Unity2dPanel()['x_absolute'].to_i
86 }
87
88 XDo::Mouse.move(0,200)
89 sleep 0.4
90- verify_equal( -WIDTH, 0, 'Launcher should not be visible immediately after mouse moves to the left edge, has to wait 0.5 seconds to show' ) {
91+ verify_equal( -LAUNCHER_WIDTH, 0, 'Launcher should not be visible immediately after mouse moves to the left edge, has to wait 0.5 seconds to show' ) {
92 @app.Unity2dPanel()['x_absolute'].to_i
93 }
94 verify_equal( 0, TIMEOUT, 'Launcher hiding when mouse at left edge of screen' ) {
95 @app.Unity2dPanel()['x_absolute'].to_i
96 }
97
98- XDo::Mouse.move(WIDTH-1,200)
99+ XDo::Mouse.move(LAUNCHER_WIDTH-1,200)
100 verify_equal( 0, TIMEOUT, 'Launcher should still be visible as mouse over it' ) {
101 @app.Unity2dPanel()['x_absolute'].to_i
102 }
103
104- XDo::Mouse.move(WIDTH,200)
105+ XDo::Mouse.move(LAUNCHER_WIDTH,200)
106 sleep 0.9
107 verify_equal( 0, 0, 'Launcher should still be visible as it should take 1 second to hide after mouse is not over it' ) {
108 @app.Unity2dPanel()['x_absolute'].to_i
109 }
110- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ) {
111+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ) {
112 @app.Unity2dPanel()['x_absolute'].to_i
113 }
114 xid.close!
115@@ -241,7 +240,7 @@
116 # * None
117 test "Hold Super key down to reveal launcher and shortcut keys" do
118 xid = TmpWindow.open_window_at(10,100)
119- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
120+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
121 @app.Unity2dPanel()['x_absolute'].to_i
122 }
123
124@@ -258,7 +257,7 @@
125 }
126
127 XDo::Keyboard.key_up('SUPER')
128- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ) {
129+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ) {
130 @app.Unity2dPanel()['x_absolute'].to_i
131 }
132 xid.close!
133@@ -283,7 +282,7 @@
134 # * None
135 test "Press Alt+F1 to focus Launcher" do
136 xid = TmpWindow.open_window_at(10,100)
137- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
138+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
139 @app.Unity2dPanel()['x_absolute'].to_i
140 }
141
142@@ -298,7 +297,7 @@
143 }
144
145 XDo::Keyboard.escape
146- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ) {
147+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ) {
148 @app.Unity2dPanel()['x_absolute'].to_i
149 }
150 xid.close!
151@@ -326,7 +325,7 @@
152 # * None
153 test "Press Alt+F1 to focus/unfocus Launcher" do
154 xid = TmpWindow.open_window_at(10,100)
155- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
156+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
157 @app.Unity2dPanel()['x_absolute'].to_i
158 }
159 assert_equal( xid.id, XDo::XWindow.active_window, \
160@@ -345,7 +344,7 @@
161 'terminal has focus when it should be in the launcher' )
162
163 XDo::Keyboard.alt_F1
164- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ){
165+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way and mouse moved out, should be hidden' ){
166 @app.Unity2dPanel()['x_absolute'].to_i
167 }
168 assert_equal( xid.id, XDo::XWindow.active_window, \
169@@ -371,7 +370,7 @@
170 # * None
171 test "Launcher visible on show-desktop" do
172 xid = TmpWindow.open_window_at(10,100)
173- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
174+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
175 @app.Unity2dPanel()['x_absolute'].to_i
176 }
177
178@@ -381,7 +380,7 @@
179 }
180
181 XDo::XWindow.toggle_minimize_all
182- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
183+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
184 @app.Unity2dPanel()['x_absolute'].to_i
185 }
186 xid.close!
187@@ -425,7 +424,7 @@
188 verify_equal( 0, 0, 'Launcher hiding after icon removal, should be visible for 1 second' ) {
189 @app.Unity2dPanel()['x_absolute'].to_i
190 }
191- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
192+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
193 @app.Unity2dPanel()['x_absolute'].to_i
194 }
195 xid.close!
196@@ -449,7 +448,7 @@
197 # * None
198 test "Launcher visible after toggling dash" do
199 xid = TmpWindow.open_window_at(10,100)
200- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
201+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
202 @app.Unity2dPanel()['x_absolute'].to_i
203 }
204
205@@ -462,7 +461,7 @@
206 bfb.tap()
207 bfb.tap()
208 verify_not(0, 'Launcher hiding after hovering mouse over bfb and clicking twice') {
209- verify_equal( -WIDTH, 2 ) {
210+ verify_equal( -LAUNCHER_WIDTH, 2 ) {
211 @app.Unity2dPanel()['x_absolute'].to_i
212 }
213 }
214@@ -488,7 +487,7 @@
215 # * None
216 test "Launcher does not hide on Esc after Alt+F1 with overlapping window" do
217 xid = TmpWindow.open_window_at(10,100)
218- verify_equal( -WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
219+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher visible with window in the way, should be hidden' ) {
220 @app.Unity2dPanel()['x_absolute'].to_i
221 }
222 XDo::Keyboard.alt_F1 #Must use uppercase F to indicate function keys
223@@ -496,7 +495,7 @@
224 bfb.move_mouse()
225 XDo::Keyboard.escape
226 verify_not(0, 'Launcher hiding after hovering mouse over bfb and clicking twice') {
227- verify_equal( -WIDTH, 2 ) {
228+ verify_equal( -LAUNCHER_WIDTH, 2 ) {
229 @app.Unity2dPanel()['x_absolute'].to_i
230 }
231 }
232
233=== modified file 'tests/launcher/launcher_sizing.rb'
234--- tests/launcher/launcher_sizing.rb 2012-01-25 08:17:38 +0000
235+++ tests/launcher/launcher_sizing.rb 2012-01-26 12:58:23 +0000
236@@ -30,7 +30,6 @@
237
238 ############################# Test Suite #############################
239 context "Sizing tests" do
240- PANEL_HEIGHT=24
241 # Run once at the beginning of this test suite
242 startup do
243 $SUT.execute_shell_command 'killall unity-2d-launcher'
244
245=== added file 'tests/misc/lib/definitions.rb'
246--- tests/misc/lib/definitions.rb 1970-01-01 00:00:00 +0000
247+++ tests/misc/lib/definitions.rb 2012-01-26 12:58:23 +0000
248@@ -0,0 +1,3 @@
249+
250+LAUNCHER_WIDTH = 65
251+PANEL_HEIGHT = 24
252
253=== modified file 'tests/run-tests.rb'
254--- tests/run-tests.rb 2012-01-24 11:47:05 +0000
255+++ tests/run-tests.rb 2012-01-26 12:58:23 +0000
256@@ -56,6 +56,9 @@
257 UNITY_2D_SPREAD = 'unity-2d-spread'
258 end
259
260+# Require a file with some common constants
261+require $library_path+ '/definitions.rb'
262+
263 # The following line includes the complete tdriver environment
264 require 'tdriver'
265 include TDriverVerify

Subscribers

People subscribed via source and target branches