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

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

Issue 2694623016: chromeos: Makes AshTestBase/Helper target mash when appropriate (Closed)
Patch Set: comment Created 3 years, 10 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 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/ash_view_ids.h" 7 #include "ash/common/ash_view_ids.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_constants.h"
13 #include "ash/common/system/tray/tray_popup_header_button.h" 13 #include "ash/common/system/tray/tray_popup_header_button.h"
14 #include "ash/common/system/tray/view_click_listener.h" 14 #include "ash/common/system/tray/view_click_listener.h"
15 #include "ash/common/wm_shell.h"
msw 2017/02/19 21:49:20 nit: needed?
sky 2017/02/21 17:06:50 Done.
15 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
16 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
17 #include "base/run_loop.h" 18 #include "base/run_loop.h"
18 #include "base/test/scoped_mock_time_message_loop_task_runner.h" 19 #include "base/test/scoped_mock_time_message_loop_task_runner.h"
19 #include "base/test/test_mock_time_task_runner.h" 20 #include "base/test/test_mock_time_task_runner.h"
20 #include "grit/ash_resources.h" 21 #include "grit/ash_resources.h"
21 #include "grit/ash_strings.h" 22 #include "grit/ash_strings.h"
22 #include "ui/events/test/event_generator.h" 23 #include "ui/events/test/event_generator.h"
23 #include "ui/views/controls/button/button.h" 24 #include "ui/views/controls/button/button.h"
24 #include "ui/views/view.h" 25 #include "ui/views/view.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 120 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
120 RunAllPendingInMessageLoop(); 121 RunAllPendingInMessageLoop();
121 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING); 122 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING);
122 RunAllPendingInMessageLoop(); 123 RunAllPendingInMessageLoop();
123 124
124 return test_item->detailed_view()->tray_popup_header_button(); 125 return test_item->detailed_view()->tray_popup_header_button();
125 } 126 }
126 127
127 void TransitionFromDetailedToDefaultView(TestDetailsView* detailed) { 128 void TransitionFromDetailedToDefaultView(TestDetailsView* detailed) {
128 detailed->TransitionToDefaultView(); 129 detailed->TransitionToDefaultView();
129 scoped_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds( 130 (*scoped_task_runner_)
130 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY))); 131 ->FastForwardBy(base::TimeDelta::FromMilliseconds(
132 GetTrayConstant(TRAY_POPUP_TRANSITION_TO_DEFAULT_DELAY)));
131 } 133 }
132 134
133 void FocusBackButton(TestDetailsView* detailed) { 135 void FocusBackButton(TestDetailsView* detailed) {
134 detailed->back_button_->RequestFocus(); 136 detailed->back_button_->RequestFocus();
135 } 137 }
136 138
139 void SetUp() override {
140 AshTestBase::SetUp();
141 scoped_task_runner_ =
142 base::MakeUnique<base::ScopedMockTimeMessageLoopTaskRunner>();
143 }
144
145 void TearDown() override {
146 scoped_task_runner_.reset();
147 AshTestBase::TearDown();
148 }
149
137 private: 150 private:
138 // Used to control the |transition_delay_timer_|. 151 // Used to control the |transition_delay_timer_|.
139 base::ScopedMockTimeMessageLoopTaskRunner scoped_task_runner_; 152 std::unique_ptr<base::ScopedMockTimeMessageLoopTaskRunner>
153 scoped_task_runner_;
140 154
141 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest); 155 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest);
142 }; 156 };
143 157
144 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { 158 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
145 SystemTray* tray = GetPrimarySystemTray(); 159 SystemTray* tray = GetPrimarySystemTray();
146 ASSERT_TRUE(tray->GetWidget()); 160 ASSERT_TRUE(tray->GetWidget());
147 161
148 TestItem* test_item_1 = new TestItem; 162 TestItem* test_item_1 = new TestItem;
149 TestItem* test_item_2 = new TestItem; 163 TestItem* test_item_2 = new TestItem;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 240
227 // Sticky header layer should be above the last child's layer. 241 // Sticky header layer should be above the last child's layer.
228 EXPECT_EQ(3u, layers.size()); 242 EXPECT_EQ(3u, layers.size());
229 EXPECT_EQ(view3->layer(), layers[0]); 243 EXPECT_EQ(view3->layer(), layers[0]);
230 EXPECT_EQ(view4->layer(), layers[1]); 244 EXPECT_EQ(view4->layer(), layers[1]);
231 EXPECT_EQ(view2->layer(), layers[2]); 245 EXPECT_EQ(view2->layer(), layers[2]);
232 } 246 }
233 247
234 } // namespace test 248 } // namespace test
235 } // namespace ash 249 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698