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

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

Issue 2815043002: Removes ShellPort::IsRunningInMash() (Closed)
Patch Set: dont set instance_ in constructor 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
« no previous file with comments | « ash/screen_util_unittest.cc ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/public/cpp/config.h"
9 #include "ash/shelf/wm_shelf.h" 10 #include "ash/shelf/wm_shelf.h"
10 #include "ash/shell_port.h" 11 #include "ash/shell.h"
11 #include "ash/test/ash_test_base.h" 12 #include "ash/test/ash_test_base.h"
12 #include "ash/test/shelf_button_pressed_metric_tracker_test_api.h" 13 #include "ash/test/shelf_button_pressed_metric_tracker_test_api.h"
13 #include "ash/test/shelf_view_test_api.h" 14 #include "ash/test/shelf_view_test_api.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/test/histogram_tester.h" 16 #include "base/test/histogram_tester.h"
16 #include "base/test/simple_test_tick_clock.h" 17 #include "base/test/simple_test_tick_clock.h"
17 #include "base/test/user_action_tester.h" 18 #include "base/test/user_action_tester.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/events/event.h" 20 #include "ui/events/event.h"
20 #include "ui/views/controls/button/button.h" 21 #include "ui/views/controls/button/button.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 metric_tracker_->ButtonPressed(kDummyEvent, sender, performed_action); 149 metric_tracker_->ButtonPressed(kDummyEvent, sender, performed_action);
149 } 150 }
150 151
151 } // namespace 152 } // namespace
152 153
153 // Verifies that a Launcher_ButtonPressed_Mouse UMA user action is recorded when 154 // Verifies that a Launcher_ButtonPressed_Mouse UMA user action is recorded when
154 // a button is pressed by a mouse event. 155 // a button is pressed by a mouse event.
155 TEST_F(ShelfButtonPressedMetricTrackerTest, 156 TEST_F(ShelfButtonPressedMetricTrackerTest,
156 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByMouse) { 157 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByMouse) {
157 // TODO: investigate failure in mash. http://crbug.com/695565. 158 // TODO: investigate failure in mash. http://crbug.com/695565.
158 if (ShellPort::Get()->IsRunningInMash()) 159 if (Shell::GetAshConfig() == Config::MASH)
159 return; 160 return;
160 161
161 const ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(), 162 const ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(),
162 gfx::Point(), base::TimeTicks(), 0, 0); 163 gfx::Point(), base::TimeTicks(), 0, 0);
163 164
164 base::UserActionTester user_action_tester; 165 base::UserActionTester user_action_tester;
165 ButtonPressed(mouse_event); 166 ButtonPressed(mouse_event);
166 EXPECT_EQ(1, 167 EXPECT_EQ(1,
167 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse")); 168 user_action_tester.GetActionCount("Launcher_ButtonPressed_Mouse"));
168 } 169 }
169 170
170 // Verifies that a Launcher_ButtonPressed_Touch UMA user action is recorded when 171 // Verifies that a Launcher_ButtonPressed_Touch UMA user action is recorded when
171 // a button is pressed by a touch event. 172 // a button is pressed by a touch event.
172 TEST_F(ShelfButtonPressedMetricTrackerTest, 173 TEST_F(ShelfButtonPressedMetricTrackerTest,
173 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByTouch) { 174 Launcher_ButtonPressed_MouseIsRecordedWhenIconActivatedByTouch) {
174 // TODO: investigate failure in mash. http://crbug.com/695565. 175 // TODO: investigate failure in mash. http://crbug.com/695565.
175 if (ShellPort::Get()->IsRunningInMash()) 176 if (Shell::GetAshConfig() == Config::MASH)
176 return; 177 return;
177 178
178 const ui::TouchEvent touch_event( 179 const ui::TouchEvent touch_event(
179 ui::ET_GESTURE_TAP, gfx::Point(), base::TimeTicks(), 180 ui::ET_GESTURE_TAP, gfx::Point(), base::TimeTicks(),
180 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)); 181 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
181 182
182 base::UserActionTester user_action_tester; 183 base::UserActionTester user_action_tester;
183 ButtonPressed(touch_event); 184 ButtonPressed(touch_event);
184 EXPECT_EQ(1, 185 EXPECT_EQ(1,
185 user_action_tester.GetActionCount("Launcher_ButtonPressed_Touch")); 186 user_action_tester.GetActionCount("Launcher_ButtonPressed_Touch"));
186 } 187 }
187 188
188 // Verifies that a Launcher_LaunchTask UMA user action is recorded when 189 // Verifies that a Launcher_LaunchTask UMA user action is recorded when
189 // pressing a button causes a new window to be created. 190 // pressing a button causes a new window to be created.
190 TEST_F(ShelfButtonPressedMetricTrackerTest, 191 TEST_F(ShelfButtonPressedMetricTrackerTest,
191 Launcher_LaunchTaskIsRecordedWhenNewWindowIsCreated) { 192 Launcher_LaunchTaskIsRecordedWhenNewWindowIsCreated) {
192 // TODO: investigate failure in mash. http://crbug.com/695565. 193 // TODO: investigate failure in mash. http://crbug.com/695565.
193 if (ShellPort::Get()->IsRunningInMash()) 194 if (Shell::GetAshConfig() == Config::MASH)
194 return; 195 return;
195 196
196 base::UserActionTester user_action_tester; 197 base::UserActionTester user_action_tester;
197 ButtonPressed(SHELF_ACTION_NEW_WINDOW_CREATED); 198 ButtonPressed(SHELF_ACTION_NEW_WINDOW_CREATED);
198 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask")); 199 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_LaunchTask"));
199 } 200 }
200 201
201 // Verifies that a Launcher_MinimizeTask UMA user action is recorded when 202 // Verifies that a Launcher_MinimizeTask UMA user action is recorded when
202 // pressing a button causes an existing window to be minimized. 203 // pressing a button causes an existing window to be minimized.
203 TEST_F(ShelfButtonPressedMetricTrackerTest, 204 TEST_F(ShelfButtonPressedMetricTrackerTest,
204 Launcher_MinimizeTaskIsRecordedWhenWindowIsMinimized) { 205 Launcher_MinimizeTaskIsRecordedWhenWindowIsMinimized) {
205 // TODO: investigate failure in mash. http://crbug.com/695565. 206 // TODO: investigate failure in mash. http://crbug.com/695565.
206 if (ShellPort::Get()->IsRunningInMash()) 207 if (Shell::GetAshConfig() == Config::MASH)
207 return; 208 return;
208 209
209 base::UserActionTester user_action_tester; 210 base::UserActionTester user_action_tester;
210 ButtonPressed(SHELF_ACTION_WINDOW_MINIMIZED); 211 ButtonPressed(SHELF_ACTION_WINDOW_MINIMIZED);
211 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_MinimizeTask")); 212 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_MinimizeTask"));
212 } 213 }
213 214
214 // Verifies that a Launcher_SwitchTask UMA user action is recorded when 215 // Verifies that a Launcher_SwitchTask UMA user action is recorded when
215 // pressing a button causes an existing window to be activated. 216 // pressing a button causes an existing window to be activated.
216 TEST_F(ShelfButtonPressedMetricTrackerTest, 217 TEST_F(ShelfButtonPressedMetricTrackerTest,
217 Launcher_SwitchTaskIsRecordedWhenExistingWindowIsActivated) { 218 Launcher_SwitchTaskIsRecordedWhenExistingWindowIsActivated) {
218 // TODO: investigate failure in mash. http://crbug.com/695565. 219 // TODO: investigate failure in mash. http://crbug.com/695565.
219 if (ShellPort::Get()->IsRunningInMash()) 220 if (Shell::GetAshConfig() == Config::MASH)
220 return; 221 return;
221 222
222 base::UserActionTester user_action_tester; 223 base::UserActionTester user_action_tester;
223 ButtonPressed(SHELF_ACTION_WINDOW_ACTIVATED); 224 ButtonPressed(SHELF_ACTION_WINDOW_ACTIVATED);
224 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_SwitchTask")); 225 EXPECT_EQ(1, user_action_tester.GetActionCount("Launcher_SwitchTask"));
225 } 226 }
226 227
227 // Verify that a window activation action will record a data point if it was 228 // Verify that a window activation action will record a data point if it was
228 // subsequent to a minimize action. 229 // subsequent to a minimize action.
229 TEST_F(ShelfButtonPressedMetricTrackerTest, 230 TEST_F(ShelfButtonPressedMetricTrackerTest,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 307
307 histogram_tester.ExpectTotalCount( 308 histogram_tester.ExpectTotalCount(
308 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1); 309 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 1);
309 histogram_tester.ExpectBucketCount( 310 histogram_tester.ExpectBucketCount(
310 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName, 311 kTimeBetweenWindowMinimizedAndActivatedActionsHistogramName,
311 kTimeDeltaInMilliseconds, 1); 312 kTimeDeltaInMilliseconds, 1);
312 } 313 }
313 314
314 } // namespace test 315 } // namespace test
315 } // namespace ash 316 } // namespace ash
OLDNEW
« no previous file with comments | « ash/screen_util_unittest.cc ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698