OLD | NEW |
---|---|
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 Loading... | |
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_.task_runner()->FastForwardBy( | |
gab
2016/11/18 18:18:54
scoped_task_runner_->FastForwardBy()
should work
bruthig
2016/11/18 18:47:59
Done.
| |
143 base::TimeDelta::FromMilliseconds( | |
144 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY))); | |
139 } | 145 } |
140 | 146 |
141 void FocusBackButton(TestDetailsView* detailed) { | 147 void FocusBackButton(TestDetailsView* detailed) { |
142 detailed->back_button_->RequestFocus(); | 148 detailed->back_button_->RequestFocus(); |
143 } | 149 } |
144 | 150 |
145 private: | 151 private: |
152 // Used to control the |transition_delay_timer_|. | |
153 base::ScopedMockTimeMessageLoopTaskRunner scoped_task_runner_; | |
154 | |
146 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest); | 155 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest); |
147 }; | 156 }; |
148 | 157 |
149 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { | 158 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { |
150 SystemTray* tray = GetPrimarySystemTray(); | 159 SystemTray* tray = GetPrimarySystemTray(); |
151 ASSERT_TRUE(tray->GetWidget()); | 160 ASSERT_TRUE(tray->GetWidget()); |
152 | 161 |
153 TestItem* test_item_1 = new TestItem; | 162 TestItem* test_item_1 = new TestItem; |
154 TestItem* test_item_2 = new TestItem; | 163 TestItem* test_item_2 = new TestItem; |
155 tray->AddTrayItem(test_item_1); | 164 tray->AddTrayItem(test_item_1); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 gfx::Rect bounds = button->GetBoundsInScreen(); | 308 gfx::Rect bounds = button->GetBoundsInScreen(); |
300 gfx::Point initial_point(bounds.x() - 1, bounds.y()); | 309 gfx::Point initial_point(bounds.x() - 1, bounds.y()); |
301 generator.set_current_location(initial_point); | 310 generator.set_current_location(initial_point); |
302 generator.MoveMouseBy(1, 0); | 311 generator.MoveMouseBy(1, 0); |
303 RunAllPendingInMessageLoop(); | 312 RunAllPendingInMessageLoop(); |
304 EXPECT_TRUE(button->background()); | 313 EXPECT_TRUE(button->background()); |
305 } | 314 } |
306 | 315 |
307 } // namespace test | 316 } // namespace test |
308 } // namespace ash | 317 } // namespace ash |
OLD | NEW |