Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(662)

Side by Side Diff: ash/shelf/shelf_button_pressed_metric_tracker_unittest.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_button_pressed_metric_tracker.h" 5 #include "ash/shelf/shelf_button_pressed_metric_tracker.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/shelf/wm_shelf.h" 9 #include "ash/shelf/wm_shelf.h"
10 #include "ash/shell_port.h"
10 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
11 #include "ash/test/shelf_button_pressed_metric_tracker_test_api.h" 12 #include "ash/test/shelf_button_pressed_metric_tracker_test_api.h"
12 #include "ash/test/shelf_view_test_api.h" 13 #include "ash/test/shelf_view_test_api.h"
13 #include "ash/wm_shell.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/test/histogram_tester.h" 15 #include "base/test/histogram_tester.h"
16 #include "base/test/simple_test_tick_clock.h" 16 #include "base/test/simple_test_tick_clock.h"
17 #include "base/test/user_action_tester.h" 17 #include "base/test/user_action_tester.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/views/controls/button/button.h" 20 #include "ui/views/controls/button/button.h"
21 21
22 namespace ash { 22 namespace ash {
23 namespace test { 23 namespace test {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 metric_tracker_->ButtonPressed(kDummyEvent, sender, performed_action); 148 metric_tracker_->ButtonPressed(kDummyEvent, sender, performed_action);
149 } 149 }
150 150
151 } // namespace 151 } // namespace
152 152
153 // Verifies that a Launcher_ButtonPressed_Mouse UMA user action is recorded when 153 // Verifies that a Launcher_ButtonPressed_Mouse UMA user action is recorded when
154 // a button is pressed by a mouse event. 154 // a button is pressed by a mouse event.
155 TEST_F(ShelfButtonPressedMetricTrackerTest, 155 TEST_F(ShelfButtonPressedMetricTrackerTest,
156 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByMouse) { 156 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByMouse) {
157 // TODO: investigate failure in mash. http://crbug.com/695565. 157 // TODO: investigate failure in mash. http://crbug.com/695565.
158 if (WmShell::Get()->IsRunningInMash()) 158 if (ShellPort::Get()->IsRunningInMash())
159 return; 159 return;
160 160
161 const ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(), 161 const ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(),
162 gfx::Point(), base::TimeTicks(), 0, 0); 162 gfx::Point(), base::TimeTicks(), 0, 0);
163 163
164 base::UserActionTester user_action_tester; 164 base::UserActionTester user_action_tester;
165 ButtonPressed(mouse_event); 165 ButtonPressed(mouse_event);
166 EXPECT_EQ(1, 166 EXPECT_EQ(1,
167 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); 167 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse"));
168 } 168 }
169 169
170 // Verifies that a Launcher_ButtonPressed_Touch UMA user action is recorded when 170 // Verifies that a Launcher_ButtonPressed_Touch UMA user action is recorded when
171 // a button is pressed by a touch event. 171 // a button is pressed by a touch event.
172 TEST_F(ShelfButtonPressedMetricTrackerTest, 172 TEST_F(ShelfButtonPressedMetricTrackerTest,
173 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByTouch) { 173 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByTouch) {
174 // TODO: investigate failure in mash. http://crbug.com/695565. 174 // TODO: investigate failure in mash. http://crbug.com/695565.
175 if (WmShell::Get()->IsRunningInMash()) 175 if (ShellPort::Get()->IsRunningInMash())
176 return; 176 return;
177 177
178 const ui::TouchEvent touch_event( 178 const ui::TouchEvent touch_event(
179 ui::ET_GESTURE_TAP, gfx::Point(), base::TimeTicks(), 179 ui::ET_GESTURE_TAP, gfx::Point(), base::TimeTicks(),
180 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)); 180 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
181 181
182 base::UserActionTester user_action_tester; 182 base::UserActionTester user_action_tester;
183 ButtonPressed(touch_event); 183 ButtonPressed(touch_event);
184 EXPECT_EQ(1, 184 EXPECT_EQ(1,
185 user_action_tester.GetActionCount("Launcher_ButtonPressed_Touch")); 185 user_action_tester.GetActionCount("Launcher_ButtonPressed_Touch"));
186 } 186 }
187 187
188 // Verifies that a Launcher_LaunchTask UMA user action is recorded when 188 // Verifies that a Launcher_LaunchTask UMA user action is recorded when
189 // pressing a button causes a new window to be created. 189 // pressing a button causes a new window to be created.
190 TEST_F(ShelfButtonPressedMetricTrackerTest, 190 TEST_F(ShelfButtonPressedMetricTrackerTest,
191 Launcher_LaunchTaskIsRecordedWhenNewWindowIsCreated) { 191 Launcher_LaunchTaskIsRecordedWhenNewWindowIsCreated) {
192 // TODO: investigate failure in mash. http://crbug.com/695565. 192 // TODO: investigate failure in mash. http://crbug.com/695565.
193 if (WmShell::Get()->IsRunningInMash()) 193 if (ShellPort::Get()->IsRunningInMash())
194 return; 194 return;
195 195
196 base::UserActionTester user_action_tester; 196 base::UserActionTester user_action_tester;
197 ButtonPressed(SHELF_ACTION_NEW_WINDOW_CREATED); 197 ButtonPressed(SHELF_ACTION_NEW_WINDOW_CREATED);
198 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask")); 198 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask"));
199 } 199 }
200 200
201 // Verifies that a Launcher_MinimizeTask UMA user action is recorded when 201 // Verifies that a Launcher_MinimizeTask UMA user action is recorded when
202 // pressing a button causes an existing window to be minimized. 202 // pressing a button causes an existing window to be minimized.
203 TEST_F(ShelfButtonPressedMetricTrackerTest, 203 TEST_F(ShelfButtonPressedMetricTrackerTest,
204 Launcher_MinimizeTaskIsRecordedWhenWindowIsMinimized) { 204 Launcher_MinimizeTaskIsRecordedWhenWindowIsMinimized) {
205 // TODO: investigate failure in mash. http://crbug.com/695565. 205 // TODO: investigate failure in mash. http://crbug.com/695565.
206 if (WmShell::Get()->IsRunningInMash()) 206 if (ShellPort::Get()->IsRunningInMash())
207 return; 207 return;
208 208
209 base::UserActionTester user_action_tester; 209 base::UserActionTester user_action_tester;
210 ButtonPressed(SHELF_ACTION_WINDOW_MINIMIZED); 210 ButtonPressed(SHELF_ACTION_WINDOW_MINIMIZED);
211 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_MinimizeTask")); 211 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_MinimizeTask"));
212 } 212 }
213 213
214 // Verifies that a Launcher_SwitchTask UMA user action is recorded when 214 // Verifies that a Launcher_SwitchTask UMA user action is recorded when
215 // pressing a button causes an existing window to be activated. 215 // pressing a button causes an existing window to be activated.
216 TEST_F(ShelfButtonPressedMetricTrackerTest, 216 TEST_F(ShelfButtonPressedMetricTrackerTest,
217 Launcher_SwitchTaskIsRecordedWhenExistingWindowIsActivated) { 217 Launcher_SwitchTaskIsRecordedWhenExistingWindowIsActivated) {
218 // TODO: investigate failure in mash. http://crbug.com/695565. 218 // TODO: investigate failure in mash. http://crbug.com/695565.
219 if (WmShell::Get()->IsRunningInMash()) 219 if (ShellPort::Get()->IsRunningInMash())
220 return; 220 return;
221 221
222 base::UserActionTester user_action_tester; 222 base::UserActionTester user_action_tester;
223 ButtonPressed(SHELF_ACTION_WINDOW_ACTIVATED); 223 ButtonPressed(SHELF_ACTION_WINDOW_ACTIVATED);
224 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_SwitchTask")); 224 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_SwitchTask"));
225 } 225 }
226 226
227 // Verify that a window activation action will record a data point if it was 227 // Verify that a window activation action will record a data point if it was
228 // subsequent to a minimize action. 228 // subsequent to a minimize action.
229 TEST_F(ShelfButtonPressedMetricTrackerTest, 229 TEST_F(ShelfButtonPressedMetricTrackerTest,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 histogram_tester.ExpectTotalCount( 307 histogram_tester.ExpectTotalCount(
308 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1); 308 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1);
309 histogram_tester.ExpectBucketCount( 309 histogram_tester.ExpectBucketCount(
310 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 310 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName,
311 kTimeDeltaInMilliseconds, 1); 311 kTimeDeltaInMilliseconds, 1);
312 } 312 }
313 313
314 } // namespace test 314 } // namespace test
315 } // namespace ash 315 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698