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

Proposed by Albert Astals Cid
Status: Merged
Approved by: MichaƂ Sawicz
Approved revision: 876
Merged at revision: 878
Proposed branch: lp:~aacid/unity-2d/unity-2d_test_dash_launcher_interactions
Merge into: lp:unity-2d
Diff against target: 97 lines (+89/-0)
1 file modified
tests/places/places-tests.rb (+89/-0)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d_test_dash_launcher_interactions
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
Review via email: mp+90155@code.launchpad.net

Description of the change

[Test] Check Super, Alt+F1 interaction and Super, Super, Alt+F1 interaction

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :

You are settings many of the verify timeouts to zero. Bear in mind that the purpose of these timeouts is to give some lee-way for old/show machines or those under load from other processes at test time.

If the verify condition is true, it will return immediately. Otherwise it waits for a period (timeout) until the condition is correct, and throws fail exception is the timeout expires.

This is why asserts are not good for app testing.

I think it good to give generous timeouts to all verify statements, only exception being if you are checking on the timing of a particular condition becoming true (and those nested verify thingys).

I'm guessing it's why I got this error, as the test should pass:

Verification "Launcher should be showing after pressing Alt+F1" at ./places/places-tests.rb:202:in `test_Super__Super_and_Alt_F1_interaction' failed as an exception was thrown when the verification block was executed
=> verify_not(0, 'Launcher should be showing after pressing Alt+F1') {
         verify_true( 1 ) {
           @app_launcher.Unity2dPanel()['x_absolute'].to_i != 0

Details:
#<TypeError: exception object expected>

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

Also
+ WIDTH = 65
gives me a warning.

Today I just learned that defining a constant in a class in Ruby defines it globally, not just in the class :)

So we need to fix up constants. We should add a file with basic constants: LAUNCHER_WIDTH, PANEL_HEIGHT, DASH_WIDTH, etc.. which we can reference everywhere.

Revision history for this message
Albert Astals Cid (aacid) wrote :

The timeouts to 0 are for the same conditions that exist in the previous tests already.

Actually i'm confused about the message you get, it says "an exception was thrown when the verification block was executed", well that's exactly when verify_not is supposed to succeed, isn't it?

About the WIDTH thing do you want me to create a separate MR for that?

Revision history for this message
Gerry Boland (gerboland) wrote :

> The timeouts to 0 are for the same conditions that exist in the previous tests already.

+ XDo::Keyboard.alt_F1 #Must use uppercase F to indicate function keys
+ verify_not(0, 'There should not be a Dash declarative view after pressing Alt+F1') {
+ @app_places.DashDeclarativeView()
+ }

Yep I see what you mean, but taking the above, if it takes the program a second to react to Alt+F1 and destroy the DashDeclarativeView, the verify_not will have already timed out and thrown a fail.

I'm encouraging TIMEOUTs as much as possible. They cause no harm, do they?

Revision history for this message
Gerry Boland (gerboland) wrote :

> Actually i'm confused about the message you get, it says "an exception was thrown
> when the verification block was executed", well that's exactly when verify_not is
> supposed to succeed, isn't it?

Hmm, verify_not expects an exception, else it fails. This means verify_true returned without throwing an exception, so
@app_launcher.Unity2dPanel()['x_absolute'].to_i != 0
was true at some stage.

Now exactly why that happened I'm not sure. True a longer timeout won't help in this case. Perhaps my machine is too fast, and panel respawned (maybe by gnome-session). I'll try again to be certain.

Revision history for this message
Gerry Boland (gerboland) wrote :

Please ignore that last sentence, I got my wires crossed :)

Revision history for this message
Albert Astals Cid (aacid) wrote :
Revision history for this message
Albert Astals Cid (aacid) wrote :

Right, the question is how/why
@app_launcher.Unity2dPanel()['x_absolute'].to_i != 0
was true at some stage during that 1 second timeout, it'd be cool if you could dig a bit more about it.

I'll try and see if adding TIMEOUTS to those 0 sec verify still makes it work for me.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Just realized the test is wrongly written, will improve it in a sec

Revision history for this message
Albert Astals Cid (aacid) wrote :

pushed a new version with bigger timeouts (2 instead of 0) and with an improved test workflow

Revision history for this message
Gerry Boland (gerboland) wrote :

Ok, works nicely. Thanks

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity-2d failed due to conflicts:

text conflict in tests/places/places-tests.rb

Revision history for this message
Unity Merger (unity-merger) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/places/places-tests.rb'
2--- tests/places/places-tests.rb 2012-01-25 17:03:58 +0000
3+++ tests/places/places-tests.rb 2012-01-27 10:46:35 +0000
4@@ -162,4 +162,93 @@
5 }
6 }
7 end
8+
9+ # Test case objectives:
10+ # * Check Super and Alt+F1 interaction
11+ # Pre-conditions
12+ # * Desktop with no running applications
13+ # Test steps
14+ # * Verify dash is not showing
15+ # * Press Super
16+ # * Verify dash is showing
17+ # * Press Alt+F1
18+ # * Verify dash is not showing
19+ # * Verify launcher does not hide
20+ # Post-conditions
21+ # * None
22+ # References
23+ # * None
24+ test "Super and Alt+F1 interaction" do
25+ xid = TmpWindow.open_window_at(10,100)
26+ verify_not(2, 'There should not be a Dash declarative view on startup') {
27+ @app_places.DashDeclarativeView()
28+ }
29+ XDo::Keyboard.super
30+ verify(TIMEOUT, 'There should be a Dash declarative view after pressing Super') {
31+ @app_places.DashDeclarativeView()
32+ }
33+ XDo::Keyboard.alt_F1 #Must use uppercase F to indicate function keys
34+ verify_not(2, 'There should not be a Dash declarative view after pressing Alt+F1') {
35+ @app_places.DashDeclarativeView()
36+ }
37+ verify_not(0, 'Launcher should not hide after pressing Alt+F1') {
38+ verify_equal( -LAUNCHER_WIDTH, 2 ) {
39+ @app_launcher.Unity2dPanel()['x_absolute'].to_i
40+ }
41+ }
42+ xid.close!
43+ end
44+
45+ # Test case objectives:
46+ # * Check Super, Super and Alt+F1 interaction
47+ # Pre-conditions
48+ # * Desktop with no running applications
49+ # Test steps
50+ # * Verify dash is not showing
51+ # * Verify terminal has focus
52+ # * Press Super
53+ # * Verify dash is showing
54+ # * Press Super
55+ # * Verify dash is not showing
56+ # * Verify terminal has focus
57+ # * Verify launcher is hidden
58+ # * Press Alt+F1
59+ # * Verify dash is not showing
60+ # * Verify launcher shows
61+ # Post-conditions
62+ # * None
63+ # References
64+ # * None
65+ test "Super, Super and Alt+F1 interaction" do
66+ xid = TmpWindow.open_window_at(10,100)
67+ verify_equal( xid.id, TIMEOUT, 'terminal should have focus after starting it' ) {
68+ XDo::XWindow.active_window
69+ }
70+ verify_not(2, 'There should not be a Dash declarative view on startup') {
71+ @app_places.DashDeclarativeView()
72+ }
73+ XDo::Keyboard.super
74+ verify(TIMEOUT, 'There should be a Dash declarative view after pressing Super') {
75+ @app_places.DashDeclarativeView()
76+ }
77+ XDo::Keyboard.super
78+ verify_not(2, 'There should not be a Dash declarative view after pressing Super again') {
79+ @app_places.DashDeclarativeView()
80+ }
81+ verify_equal( xid.id, TIMEOUT, 'terminal should have focus after toggling the dash' ) {
82+ XDo::XWindow.active_window
83+ }
84+ verify_equal( -LAUNCHER_WIDTH, TIMEOUT, 'Launcher should be hiding after toggling the dash' ) {
85+ @app_launcher.Unity2dPanel()['x_absolute'].to_i
86+ }
87+ XDo::Keyboard.alt_F1 #Must use uppercase F to indicate function keys
88+ verify_not(2, 'There should not be a Dash declarative view after pressing Alt+F1') {
89+ @app_places.DashDeclarativeView()
90+ }
91+ verify_equal( 0, TIMEOUT, 'Launcher should be showing after pressing Alt+F1' ) {
92+ @app_launcher.Unity2dPanel()['x_absolute'].to_i
93+ }
94+ xid.close!
95+ end
96+
97 end

Subscribers

People subscribed via source and target branches