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

Side by Side Diff: ash/common/system/tray/tray_details_view_unittest.cc

Issue 2494943005: [ash-md] Added a delay between system menu default/detailed view transitions. (Closed)
Patch Set: Addressed danakj@ comments. Created 4 years, 1 month 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/common/system/tray/tray_details_view.cc ('k') | base/BUILD.gn » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/system/tray/tray_details_view.h" 5 #include "ash/common/system/tray/tray_details_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/tray/hover_highlight_view.h" 8 #include "ash/common/system/tray/hover_highlight_view.h"
9 #include "ash/common/system/tray/special_popup_row.h" 9 #include "ash/common/system/tray/special_popup_row.h"
10 #include "ash/common/system/tray/system_tray.h" 10 #include "ash/common/system/tray/system_tray.h"
11 #include "ash/common/system/tray/system_tray_item.h" 11 #include "ash/common/system/tray/system_tray_item.h"
12 #include "ash/common/system/tray/tray_constants.h"
12 #include "ash/common/system/tray/tray_popup_header_button.h" 13 #include "ash/common/system/tray/tray_popup_header_button.h"
13 #include "ash/common/system/tray/view_click_listener.h" 14 #include "ash/common/system/tray/view_click_listener.h"
14 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
15 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/test/scoped_mock_time_message_loop_task_runner.h"
18 #include "base/test/test_mock_time_task_runner.h"
16 #include "grit/ash_resources.h" 19 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 20 #include "grit/ash_strings.h"
18 #include "ui/events/test/event_generator.h" 21 #include "ui/events/test/event_generator.h"
19 #include "ui/views/controls/button/button.h" 22 #include "ui/views/controls/button/button.h"
20 #include "ui/views/view.h" 23 #include "ui/views/view.h"
21 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
22 25
23 namespace ash { 26 namespace ash {
24 namespace test { 27 namespace test {
25 28
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 132 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
130 RunAllPendingInMessageLoop(); 133 RunAllPendingInMessageLoop();
131 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING); 134 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING);
132 RunAllPendingInMessageLoop(); 135 RunAllPendingInMessageLoop();
133 136
134 return test_item->detailed_view()->tray_popup_header_button(); 137 return test_item->detailed_view()->tray_popup_header_button();
135 } 138 }
136 139
137 void TransitionFromDetailedToDefaultView(TestDetailsView* detailed) { 140 void TransitionFromDetailedToDefaultView(TestDetailsView* detailed) {
138 detailed->TransitionToDefaultView(); 141 detailed->TransitionToDefaultView();
142 scoped_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(
143 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY)));
139 } 144 }
140 145
141 void FocusBackButton(TestDetailsView* detailed) { 146 void FocusBackButton(TestDetailsView* detailed) {
142 detailed->back_button_->RequestFocus(); 147 detailed->back_button_->RequestFocus();
143 } 148 }
144 149
145 private: 150 private:
151 // Used to control the |transition_delay_timer_|.
152 base::ScopedMockTimeMessageLoopTaskRunner scoped_task_runner_;
153
146 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest); 154 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest);
147 }; 155 };
148 156
149 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { 157 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
150 SystemTray* tray = GetPrimarySystemTray(); 158 SystemTray* tray = GetPrimarySystemTray();
151 ASSERT_TRUE(tray->GetWidget()); 159 ASSERT_TRUE(tray->GetWidget());
152 160
153 TestItem* test_item_1 = new TestItem; 161 TestItem* test_item_1 = new TestItem;
154 TestItem* test_item_2 = new TestItem; 162 TestItem* test_item_2 = new TestItem;
155 tray->AddTrayItem(test_item_1); 163 tray->AddTrayItem(test_item_1);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 gfx::Rect bounds = button->GetBoundsInScreen(); 307 gfx::Rect bounds = button->GetBoundsInScreen();
300 gfx::Point initial_point(bounds.x() - 1, bounds.y()); 308 gfx::Point initial_point(bounds.x() - 1, bounds.y());
301 generator.set_current_location(initial_point); 309 generator.set_current_location(initial_point);
302 generator.MoveMouseBy(1, 0); 310 generator.MoveMouseBy(1, 0);
303 RunAllPendingInMessageLoop(); 311 RunAllPendingInMessageLoop();
304 EXPECT_TRUE(button->background()); 312 EXPECT_TRUE(button->background());
305 } 313 }
306 314
307 } // namespace test 315 } // namespace test
308 } // namespace ash 316 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_details_view.cc ('k') | base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698