Merge lp:~nick-dedekind/unity8/fix-autopilot-failures-1446846 into lp:unity8

Proposed by Nick Dedekind
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1752
Merged at revision: 1783
Proposed branch: lp:~nick-dedekind/unity8/fix-autopilot-failures-1446846
Merge into: lp:unity8
Diff against target: 226 lines (+96/-20)
3 files modified
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py (+13/-3)
tests/autopilot/unity8/indicators/tests/test_action_latency.py (+4/-2)
tests/mocks/indicator-service/mock-indicator-service.c (+79/-15)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/fix-autopilot-failures-1446846
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michael Zanetti (community) Needs Fixing
Albert Astals Cid (community) Approve
Review via email: mp+258411@code.launchpad.net

Commit message

Fixed issue in laggy indicator autpilot tests

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~nick-dedekind/ubuntu-settings-components/fix-maximumWaitBufferInterval

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

* Did CI run pass?
With this and it's requisite we get 2 more passing.

* Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve
Revision history for this message
Michael Zanetti (mzanetti) wrote :

whitespace test fails.

review: Needs Fixing
1753. By Nick Dedekind

fixed whitespace

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py'
2--- tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2015-04-24 16:10:02 +0000
3+++ tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py 2015-05-14 08:54:21 +0000
4@@ -21,6 +21,7 @@
5
6 import logging
7 import os
8+import threading
9
10 from autopilot.platform import model
11
12@@ -90,10 +91,19 @@
13 """Greeter should hide when an app is opened"""
14 process_helpers.lock_unity()
15
16+ # FIXME - this is because the device greeter uses a password.
17+ # Need to be able to selectively enable mocks so that we can use the fake greeter.
18+ def unlock_thread_worker(greeter):
19+ greeter.wait_swiped_away()
20+ process_helpers.unlock_unity()
21+ greeter.created.wait_for(False)
22+
23+ greeter = self.main_window.get_greeter()
24+ unlock_thread = threading.Thread(target=unlock_thread_worker, args=(greeter,))
25+ unlock_thread.start()
26 application_name = self.launch_fake_app()
27- greeter = self.main_window.get_greeter()
28- greeter.wait_swiped_away()
29- process_helpers.unlock_unity()
30+ unlock_thread.join(10)
31+
32 self.assert_current_focused_application(application_name)
33
34 def test_greeter_hides_on_app_focus(self):
35
36=== modified file 'tests/autopilot/unity8/indicators/tests/test_action_latency.py'
37--- tests/autopilot/unity8/indicators/tests/test_action_latency.py 2015-04-16 14:48:50 +0000
38+++ tests/autopilot/unity8/indicators/tests/test_action_latency.py 2015-05-14 08:54:21 +0000
39@@ -70,10 +70,11 @@
40 switch_menu = self.indicator_page.get_switch_menu()
41
42 switch.change_state()
43+ final_value = switch.checked
44
45 self.assertThat(
46 switch_menu.serverChecked,
47- Eventually(Equals(switch.checked), timeout=20)
48+ Eventually(Equals(final_value), timeout=20)
49 )
50
51 def test_slider_reaches_server_value(self):
52@@ -82,6 +83,7 @@
53
54 old_value = slider.value
55 slider.slide_left()
56+ final_value = slider.value
57
58 self.assertThat(
59 slider_menu.serverValue,
60@@ -90,7 +92,7 @@
61
62 self.assertThat(
63 slider_menu.serverValue,
64- Eventually(Equals(slider.value), timeout=20)
65+ Eventually(Equals(final_value), timeout=20)
66 )
67
68
69
70=== modified file 'tests/mocks/indicator-service/mock-indicator-service.c'
71--- tests/mocks/indicator-service/mock-indicator-service.c 2015-04-01 15:03:47 +0000
72+++ tests/mocks/indicator-service/mock-indicator-service.c 2015-05-14 08:54:21 +0000
73@@ -27,8 +27,15 @@
74 guint actions_export_id;
75 guint menu_export_id;
76 int action_delay;
77+ int change_interval;
78 } IndicatorTestService;
79
80+typedef struct
81+{
82+ GSimpleAction *action;
83+ GVariant* value;
84+} Action;
85+
86 static void
87 bus_acquired (GDBusConnection *connection,
88 const gchar *name,
89@@ -96,10 +103,10 @@
90 gboolean state = g_variant_get_boolean (v);
91 GVariant *new_state = g_variant_new_boolean (state == TRUE ? FALSE : TRUE);
92
93- g_simple_action_set_state(G_SIMPLE_ACTION(action), new_state);
94+ g_simple_action_set_state(action, new_state);
95
96 g_variant_unref (v);
97- g_message ("switching");
98+ g_message ("switching %d", state);
99 return FALSE;
100 }
101
102@@ -120,13 +127,12 @@
103 static gboolean
104 actual_slide (gpointer user_data)
105 {
106- GSimpleAction *action = user_data;
107-
108- GVariant* new_state = g_object_get_qdata (G_OBJECT (action), slider_value_quark ());
109-
110- g_simple_action_set_state(G_SIMPLE_ACTION(action), new_state);
111-
112- g_message ("switching");
113+ Action *slide_action = user_data;
114+
115+ g_simple_action_set_state(G_SIMPLE_ACTION(slide_action->action), slide_action->value);
116+ g_message ("sliding %f", g_variant_get_double(slide_action->value));
117+ free(slide_action);
118+
119 return FALSE;
120 }
121
122@@ -136,10 +142,40 @@
123 {
124 IndicatorTestService *indicator = user_data;
125
126- g_object_set_qdata (G_OBJECT (action), slider_value_quark (), g_variant_ref(value));
127-
128- g_timeout_add(indicator->action_delay, actual_slide, action);
129- g_message ("slide delay %.03f", g_variant_get_double(value));
130+ Action* slide_action = malloc(sizeof(Action));
131+ slide_action->action = action;
132+ slide_action->value = g_variant_ref(value);
133+
134+ g_timeout_add(indicator->action_delay, actual_slide, slide_action);
135+ g_message ("slide delay %f", g_variant_get_double(value));
136+}
137+
138+static gboolean
139+change_interval (gpointer user_data)
140+{
141+ g_message ("change interval");
142+
143+ IndicatorTestService *indicator = user_data;
144+
145+ GAction* action_switch = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.switch");
146+ actual_switch(G_SIMPLE_ACTION(action_switch));
147+
148+ GAction* action_checkbox = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.checkbox");
149+ actual_switch(G_SIMPLE_ACTION(action_checkbox));
150+
151+ GAction* action_accessPoint = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.accessPoint");
152+ actual_switch(G_SIMPLE_ACTION(action_accessPoint));
153+
154+ GAction* action_slider = g_action_map_lookup_action(G_ACTION_MAP(indicator->actions), "action.slider");
155+ static double old_value = 0.25;
156+ double new_value = old_value == 0.25 ? 0.75 : 0.25;
157+ old_value = new_value;
158+ Action* slide_action = malloc(sizeof(Action));
159+ slide_action->action = G_SIMPLE_ACTION(action_slider);
160+ slide_action->value = g_variant_new_double(new_value);
161+ actual_slide(slide_action);
162+
163+ return TRUE;
164 }
165
166 int
167@@ -147,6 +183,7 @@
168 {
169 IndicatorTestService indicator = { 0 };
170 indicator.action_delay = -1;
171+ indicator.change_interval = -1;
172 GMenuItem *item;
173 GMenu *submenu;
174 GActionEntry entries[] = {
175@@ -191,6 +228,27 @@
176 }
177 break;
178 }
179+
180+ case 'c':
181+ {
182+ arg += 2;
183+ if (!arg[0] && i < argc-1) {
184+ i++;
185+ int interval = -1;
186+
187+ if (sscanf(argv[i], "%d", &interval) == 1) {
188+ indicator.change_interval = interval;
189+ } else {
190+ printf("Invalid change interval value: %s\n", argv[i]);
191+ help = 1;
192+ }
193+ } else {
194+ printf("Invalid change interval value: %s\n", argv[i]);
195+ help = 1;
196+ }
197+ break;
198+ }
199+
200 case 'h':
201 help = 1;
202 break;
203@@ -201,8 +259,9 @@
204
205 if (help) {
206 printf("Usage: %s [<options>]\n"
207- " -t DELAY Action activation delay\n"
208- " -h Show this help text\n"
209+ " -t DELAY Action activation delay\n"
210+ " -c CHANGE_INTERVAL Interval to change action values\n"
211+ " -h Show this help text\n"
212 , argv[0]);
213 return 0;
214 }
215@@ -249,6 +308,11 @@
216 NULL);
217
218 loop = g_main_loop_new (NULL, FALSE);
219+
220+ if (indicator.change_interval != -1) {
221+ g_timeout_add(indicator.change_interval, change_interval, &indicator);
222+ }
223+
224 g_main_loop_run (loop);
225
226 g_object_unref (submenu);

Subscribers

People subscribed via source and target branches