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

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

Issue 2193913002: Added Ash.SystemMenu.DefaultView.VisibleRows histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Merge remote-tracking branch 'refs/remotes/branch-heads/2785' into drover_2785 Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/ash_switches.h" 10 #include "ash/common/ash_switches.h"
(...skipping 11 matching lines...) Expand all
22 #include "ash/shelf/shelf_layout_manager_observer.h" 22 #include "ash/shelf/shelf_layout_manager_observer.h"
23 #include "ash/shelf/shelf_locking_manager.h" 23 #include "ash/shelf/shelf_locking_manager.h"
24 #include "ash/shelf/shelf_view.h" 24 #include "ash/shelf/shelf_view.h"
25 #include "ash/shelf/shelf_widget.h" 25 #include "ash/shelf/shelf_widget.h"
26 #include "ash/shell.h" 26 #include "ash/shell.h"
27 #include "ash/system/status_area_widget.h" 27 #include "ash/system/status_area_widget.h"
28 #include "ash/system/tray/system_tray.h" 28 #include "ash/system/tray/system_tray.h"
29 #include "ash/test/ash_test_base.h" 29 #include "ash/test/ash_test_base.h"
30 #include "ash/test/display_manager_test_api.h" 30 #include "ash/test/display_manager_test_api.h"
31 #include "ash/test/shelf_test_api.h" 31 #include "ash/test/shelf_test_api.h"
32 #include "ash/test/test_system_tray_item.h"
32 #include "ash/wm/window_state_aura.h" 33 #include "ash/wm/window_state_aura.h"
33 #include "ash/wm/window_util.h" 34 #include "ash/wm/window_util.h"
34 #include "base/command_line.h" 35 #include "base/command_line.h"
35 #include "base/strings/utf_string_conversions.h"
36 #include "ui/aura/client/aura_constants.h" 36 #include "ui/aura/client/aura_constants.h"
37 #include "ui/aura/client/window_tree_client.h" 37 #include "ui/aura/client/window_tree_client.h"
38 #include "ui/aura/window.h" 38 #include "ui/aura/window.h"
39 #include "ui/aura/window_event_dispatcher.h" 39 #include "ui/aura/window_event_dispatcher.h"
40 #include "ui/compositor/layer.h" 40 #include "ui/compositor/layer.h"
41 #include "ui/compositor/layer_animator.h" 41 #include "ui/compositor/layer_animator.h"
42 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 42 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
43 #include "ui/display/display.h" 43 #include "ui/display/display.h"
44 #include "ui/display/manager/display_layout.h" 44 #include "ui/display/manager/display_layout.h"
45 #include "ui/display/screen.h" 45 #include "ui/display/screen.h"
46 #include "ui/events/gesture_detection/gesture_configuration.h" 46 #include "ui/events/gesture_detection/gesture_configuration.h"
47 #include "ui/events/test/event_generator.h" 47 #include "ui/events/test/event_generator.h"
48 #include "ui/views/controls/label.h"
49 #include "ui/views/layout/fill_layout.h"
50 #include "ui/views/view.h" 48 #include "ui/views/view.h"
51 #include "ui/views/widget/widget.h" 49 #include "ui/views/widget/widget.h"
52 50
53 #if defined(OS_WIN) 51 #if defined(OS_WIN)
54 #include "base/win/windows_version.h" 52 #include "base/win/windows_version.h"
55 #endif 53 #endif
56 54
57 namespace ash { 55 namespace ash {
58 namespace { 56 namespace {
59 57
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // ShelfLayoutManagerObserver: 245 // ShelfLayoutManagerObserver:
248 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override { 246 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override {
249 changed_auto_hide_state_ = true; 247 changed_auto_hide_state_ = true;
250 } 248 }
251 249
252 bool changed_auto_hide_state_; 250 bool changed_auto_hide_state_;
253 251
254 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); 252 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest);
255 }; 253 };
256 254
257 // Trivial item implementation that tracks its views for testing.
258 class TestItem : public SystemTrayItem {
259 public:
260 TestItem()
261 : SystemTrayItem(GetSystemTray()),
262 tray_view_(nullptr),
263 default_view_(nullptr),
264 detailed_view_(nullptr),
265 notification_view_(nullptr) {}
266
267 views::View* CreateTrayView(LoginStatus status) override {
268 tray_view_ = new views::View;
269 // Add a label so it has non-zero width.
270 tray_view_->SetLayoutManager(new views::FillLayout);
271 tray_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Tray")));
272 return tray_view_;
273 }
274
275 views::View* CreateDefaultView(LoginStatus status) override {
276 default_view_ = new views::View;
277 default_view_->SetLayoutManager(new views::FillLayout);
278 default_view_->AddChildView(new views::Label(base::UTF8ToUTF16("Default")));
279 return default_view_;
280 }
281
282 views::View* CreateDetailedView(LoginStatus status) override {
283 detailed_view_ = new views::View;
284 detailed_view_->SetLayoutManager(new views::FillLayout);
285 detailed_view_->AddChildView(
286 new views::Label(base::UTF8ToUTF16("Detailed")));
287 return detailed_view_;
288 }
289
290 views::View* CreateNotificationView(LoginStatus status) override {
291 notification_view_ = new views::View;
292 return notification_view_;
293 }
294
295 void DestroyTrayView() override { tray_view_ = nullptr; }
296
297 void DestroyDefaultView() override { default_view_ = nullptr; }
298
299 void DestroyDetailedView() override { detailed_view_ = nullptr; }
300
301 void DestroyNotificationView() override { notification_view_ = nullptr; }
302
303 void UpdateAfterLoginStatusChange(LoginStatus status) override {}
304
305 views::View* tray_view() const { return tray_view_; }
306 views::View* default_view() const { return default_view_; }
307 views::View* detailed_view() const { return detailed_view_; }
308 views::View* notification_view() const { return notification_view_; }
309
310 private:
311 views::View* tray_view_;
312 views::View* default_view_;
313 views::View* detailed_view_;
314 views::View* notification_view_;
315
316 DISALLOW_COPY_AND_ASSIGN(TestItem);
317 };
318
319 } // namespace 255 } // namespace
320 256
321 class ShelfLayoutManagerTest : public test::AshTestBase { 257 class ShelfLayoutManagerTest : public test::AshTestBase {
322 public: 258 public:
323 ShelfLayoutManagerTest() {} 259 ShelfLayoutManagerTest() {}
324 260
325 // Calls the private SetState() function. 261 // Calls the private SetState() function.
326 void SetState(ShelfLayoutManager* layout_manager, 262 void SetState(ShelfLayoutManager* layout_manager,
327 ShelfVisibilityState state) { 263 ShelfVisibilityState state) {
328 layout_manager->SetState(state); 264 layout_manager->SetState(state);
(...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 status_area_widget->GetWindowBoundsInScreen().CenterPoint(); 2036 status_area_widget->GetWindowBoundsInScreen().CenterPoint();
2101 generator.MoveMouseTo(center.x(), center.y()); 2037 generator.MoveMouseTo(center.x(), center.y());
2102 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 2038 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
2103 EXPECT_TRUE(layout_manager->IsVisible()); 2039 EXPECT_TRUE(layout_manager->IsVisible());
2104 if (!i) { 2040 if (!i) {
2105 // In our first iteration we make sure there is no bubble. 2041 // In our first iteration we make sure there is no bubble.
2106 tray->CloseSystemBubble(); 2042 tray->CloseSystemBubble();
2107 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 2043 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
2108 } else { 2044 } else {
2109 // In our second iteration we show a bubble. 2045 // In our second iteration we show a bubble.
2110 TestItem* item = new TestItem; 2046 test::TestSystemTrayItem* item = new test::TestSystemTrayItem();
2111 tray->AddTrayItem(item); 2047 tray->AddTrayItem(item);
2112 tray->ShowNotificationView(item); 2048 tray->ShowNotificationView(item);
2113 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 2049 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
2114 } 2050 }
2115 // Move the pointer over the edge of the shelf. 2051 // Move the pointer over the edge of the shelf.
2116 generator.MoveMouseTo( 2052 generator.MoveMouseTo(
2117 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); 2053 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8);
2118 layout_manager->UpdateVisibilityState(); 2054 layout_manager->UpdateVisibilityState();
2119 if (i) { 2055 if (i) {
2120 EXPECT_TRUE(layout_manager->IsVisible()); 2056 EXPECT_TRUE(layout_manager->IsVisible());
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 ->shelf_widget() 2201 ->shelf_widget()
2266 ->status_area_widget(); 2202 ->status_area_widget();
2267 EXPECT_TRUE(status_area_widget->IsVisible()); 2203 EXPECT_TRUE(status_area_widget->IsVisible());
2268 // Shelf should be in the first display's area. 2204 // Shelf should be in the first display's area.
2269 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2205 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2270 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2206 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2271 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2207 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2272 } 2208 }
2273 2209
2274 } // namespace ash 2210 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/user/tray_user_separator.cc ('k') | ash/system/chromeos/bluetooth/tray_bluetooth.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698