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

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

Issue 2434553003: [Ash MD] Restore focus on detailed row when exiting detailed view (Closed)
Patch Set: rebase Created 4 years, 2 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/common/system/tray/tray_details_view.cc ('k') | no next file » | 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"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING); 131 tray->ShowDetailedView(test_item, 0, true, BUBBLE_USE_EXISTING);
132 RunAllPendingInMessageLoop(); 132 RunAllPendingInMessageLoop();
133 133
134 return test_item->detailed_view()->tray_popup_header_button(); 134 return test_item->detailed_view()->tray_popup_header_button();
135 } 135 }
136 136
137 void TransitionFromDetailedToDefaultView(TestDetailsView* detailed) { 137 void TransitionFromDetailedToDefaultView(TestDetailsView* detailed) {
138 detailed->TransitionToDefaultView(); 138 detailed->TransitionToDefaultView();
139 } 139 }
140 140
141 void FocusBackButton(TestDetailsView* detailed) {
142 detailed->back_button_->RequestFocus();
143 }
144
141 private: 145 private:
142 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest); 146 DISALLOW_COPY_AND_ASSIGN(TrayDetailsViewTest);
143 }; 147 };
144 148
145 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) { 149 TEST_F(TrayDetailsViewTest, TransitionToDefaultViewTest) {
146 SystemTray* tray = GetPrimarySystemTray(); 150 SystemTray* tray = GetPrimarySystemTray();
147 ASSERT_TRUE(tray->GetWidget()); 151 ASSERT_TRUE(tray->GetWidget());
148 152
149 TestItem* test_item_1 = new TestItem; 153 TestItem* test_item_1 = new TestItem;
150 TestItem* test_item_2 = new TestItem; 154 TestItem* test_item_2 = new TestItem;
151 tray->AddTrayItem(test_item_1); 155 tray->AddTrayItem(test_item_1);
152 tray->AddTrayItem(test_item_2); 156 tray->AddTrayItem(test_item_2);
153 157
154 // Ensure the tray views are created. 158 // Ensure the tray views are created.
155 ASSERT_TRUE(test_item_1->tray_view() != NULL); 159 ASSERT_TRUE(test_item_1->tray_view() != NULL);
156 ASSERT_TRUE(test_item_2->tray_view() != NULL); 160 ASSERT_TRUE(test_item_2->tray_view() != NULL);
157 161
158 // Show the default view. 162 // Show the default view.
159 tray->ShowDefaultView(BUBBLE_CREATE_NEW); 163 tray->ShowDefaultView(BUBBLE_CREATE_NEW);
160 RunAllPendingInMessageLoop(); 164 RunAllPendingInMessageLoop();
161 165
162 // Show the detailed view of item 2. 166 // Show the detailed view of item 2.
163 tray->ShowDetailedView(test_item_2, 0, true, BUBBLE_USE_EXISTING); 167 tray->ShowDetailedView(test_item_2, 0, true, BUBBLE_USE_EXISTING);
164 EXPECT_TRUE(test_item_2->detailed_view()); 168 EXPECT_TRUE(test_item_2->detailed_view());
165 RunAllPendingInMessageLoop(); 169 RunAllPendingInMessageLoop();
166 EXPECT_FALSE(test_item_2->default_view()); 170 EXPECT_FALSE(test_item_2->default_view());
167 171
168 // Transition back to default view, the default view of item 2 should have 172 // Transition back to default view, the default view of item 2 should have
169 // focus. 173 // focus.
170 test_item_2->detailed_view()->FocusTitleRow(); 174 if (MaterialDesignController::IsSystemTrayMenuMaterial())
175 FocusBackButton(test_item_2->detailed_view());
176 else
177 test_item_2->detailed_view()->FocusTitleRow();
171 TransitionFromDetailedToDefaultView(test_item_2->detailed_view()); 178 TransitionFromDetailedToDefaultView(test_item_2->detailed_view());
172 RunAllPendingInMessageLoop(); 179 RunAllPendingInMessageLoop();
173 180
174 EXPECT_TRUE(test_item_2->default_view()); 181 EXPECT_TRUE(test_item_2->default_view());
175 EXPECT_FALSE(test_item_2->detailed_view()); 182 EXPECT_FALSE(test_item_2->detailed_view());
176 EXPECT_TRUE(test_item_2->default_view()->HasFocus()); 183 EXPECT_TRUE(test_item_2->default_view()->HasFocus());
177 184
178 // Show the detailed view of item 2 again. 185 // Show the detailed view of item 2 again.
179 tray->ShowDetailedView(test_item_2, 0, true, BUBBLE_USE_EXISTING); 186 tray->ShowDetailedView(test_item_2, 0, true, BUBBLE_USE_EXISTING);
180 EXPECT_TRUE(test_item_2->detailed_view()); 187 EXPECT_TRUE(test_item_2->detailed_view());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 gfx::Rect bounds = button->GetBoundsInScreen(); 298 gfx::Rect bounds = button->GetBoundsInScreen();
292 gfx::Point initial_point(bounds.x() - 1, bounds.y()); 299 gfx::Point initial_point(bounds.x() - 1, bounds.y());
293 generator.set_current_location(initial_point); 300 generator.set_current_location(initial_point);
294 generator.MoveMouseBy(1, 0); 301 generator.MoveMouseBy(1, 0);
295 RunAllPendingInMessageLoop(); 302 RunAllPendingInMessageLoop();
296 EXPECT_TRUE(button->background()); 303 EXPECT_TRUE(button->background());
297 } 304 }
298 305
299 } // namespace test 306 } // namespace test
300 } // namespace ash 307 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/tray/tray_details_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698