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

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

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_unittest.cc » ('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 (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/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 19 matching lines...) Expand all
30 #include "ash/wm/window_util.h" 30 #include "ash/wm/window_util.h"
31 #include "base/command_line.h" 31 #include "base/command_line.h"
32 #include "base/strings/utf_string_conversions.h" 32 #include "base/strings/utf_string_conversions.h"
33 #include "ui/aura/client/aura_constants.h" 33 #include "ui/aura/client/aura_constants.h"
34 #include "ui/aura/client/window_tree_client.h" 34 #include "ui/aura/client/window_tree_client.h"
35 #include "ui/aura/window.h" 35 #include "ui/aura/window.h"
36 #include "ui/aura/window_event_dispatcher.h" 36 #include "ui/aura/window_event_dispatcher.h"
37 #include "ui/compositor/layer.h" 37 #include "ui/compositor/layer.h"
38 #include "ui/compositor/layer_animator.h" 38 #include "ui/compositor/layer_animator.h"
39 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 39 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
40 #include "ui/display/display.h"
40 #include "ui/display/manager/display_layout.h" 41 #include "ui/display/manager/display_layout.h"
42 #include "ui/display/screen.h"
41 #include "ui/events/gesture_detection/gesture_configuration.h" 43 #include "ui/events/gesture_detection/gesture_configuration.h"
42 #include "ui/events/test/event_generator.h" 44 #include "ui/events/test/event_generator.h"
43 #include "ui/gfx/display.h"
44 #include "ui/gfx/screen.h"
45 #include "ui/views/controls/label.h" 45 #include "ui/views/controls/label.h"
46 #include "ui/views/layout/fill_layout.h" 46 #include "ui/views/layout/fill_layout.h"
47 #include "ui/views/view.h" 47 #include "ui/views/view.h"
48 #include "ui/views/widget/widget.h" 48 #include "ui/views/widget/widget.h"
49 49
50 #if defined(OS_WIN) 50 #if defined(OS_WIN)
51 #include "base/win/windows_version.h" 51 #include "base/win/windows_version.h"
52 #endif 52 #endif
53 53
54 namespace ash { 54 namespace ash {
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 ShelfLayoutManager* manager = shelf->shelf_layout_manager(); 701 ShelfLayoutManager* manager = shelf->shelf_layout_manager();
702 // Force an initial layout. 702 // Force an initial layout.
703 manager->LayoutShelf(); 703 manager->LayoutShelf();
704 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); 704 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state());
705 705
706 gfx::Rect status_bounds( 706 gfx::Rect status_bounds(
707 shelf->status_area_widget()->GetWindowBoundsInScreen()); 707 shelf->status_area_widget()->GetWindowBoundsInScreen());
708 gfx::Rect shelf_bounds( 708 gfx::Rect shelf_bounds(
709 shelf->GetWindowBoundsInScreen()); 709 shelf->GetWindowBoundsInScreen());
710 int shelf_height = manager->GetIdealBounds().height(); 710 int shelf_height = manager->GetIdealBounds().height();
711 gfx::Screen* screen = gfx::Screen::GetScreen(); 711 display::Screen* screen = display::Screen::GetScreen();
712 gfx::Display display = screen->GetDisplayNearestWindow( 712 display::Display display =
713 Shell::GetPrimaryRootWindow()); 713 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
714 ASSERT_NE(-1, display.id()); 714 ASSERT_NE(-1, display.id());
715 // Bottom inset should be the max of widget heights. 715 // Bottom inset should be the max of widget heights.
716 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); 716 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom());
717 717
718 // Hide the shelf. 718 // Hide the shelf.
719 SetState(manager, SHELF_HIDDEN); 719 SetState(manager, SHELF_HIDDEN);
720 // Run the animation to completion. 720 // Run the animation to completion.
721 StepWidgetLayerAnimatorToEnd(shelf); 721 StepWidgetLayerAnimatorToEnd(shelf);
722 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); 722 StepWidgetLayerAnimatorToEnd(shelf->status_area_widget());
723 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); 723 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state());
(...skipping 30 matching lines...) Expand all
754 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 754 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
755 ShelfWidget* shelf = GetShelfWidget(); 755 ShelfWidget* shelf = GetShelfWidget();
756 // Force an initial layout. 756 // Force an initial layout.
757 shelf->shelf_layout_manager()->LayoutShelf(); 757 shelf->shelf_layout_manager()->LayoutShelf();
758 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); 758 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state());
759 759
760 // Hide the shelf. 760 // Hide the shelf.
761 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); 761 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN);
762 shelf->shelf_layout_manager()->LayoutShelf(); 762 shelf->shelf_layout_manager()->LayoutShelf();
763 EXPECT_EQ(SHELF_HIDDEN, shelf->shelf_layout_manager()->visibility_state()); 763 EXPECT_EQ(SHELF_HIDDEN, shelf->shelf_layout_manager()->visibility_state());
764 gfx::Display display = gfx::Screen::GetScreen()->GetDisplayNearestWindow( 764 display::Display display =
765 Shell::GetPrimaryRootWindow()); 765 display::Screen::GetScreen()->GetDisplayNearestWindow(
766 Shell::GetPrimaryRootWindow());
766 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 767 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
767 768
768 // Make sure the bounds of the two widgets changed. 769 // Make sure the bounds of the two widgets changed.
769 EXPECT_GE(shelf->GetNativeView()->bounds().y(), 770 EXPECT_GE(
770 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); 771 shelf->GetNativeView()->bounds().y(),
771 EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), 772 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom());
772 gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); 773 EXPECT_GE(
774 shelf->status_area_widget()->GetNativeView()->bounds().y(),
775 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom());
773 } 776 }
774 777
775 // Test that switching to a different visibility state does not restart the 778 // Test that switching to a different visibility state does not restart the
776 // shelf show / hide animation if it is already running. (crbug.com/250918) 779 // shelf show / hide animation if it is already running. (crbug.com/250918)
777 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { 780 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) {
778 ShelfWidget* shelf = GetShelfWidget(); 781 ShelfWidget* shelf = GetShelfWidget();
779 SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); 782 SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE);
780 gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen(); 783 gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen();
781 gfx::Rect initial_status_bounds = 784 gfx::Rect initial_status_bounds =
782 shelf->status_area_widget()->GetWindowBoundsInScreen(); 785 shelf->status_area_widget()->GetWindowBoundsInScreen();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 widget->Show(); 841 widget->Show();
839 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 842 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
840 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 843 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
841 844
842 // LayoutShelf() forces the animation to completion, at which point the 845 // LayoutShelf() forces the animation to completion, at which point the
843 // shelf should go off the screen. 846 // shelf should go off the screen.
844 shelf->LayoutShelf(); 847 shelf->LayoutShelf();
845 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 848 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
846 GetShelfWidget()->GetWindowBoundsInScreen().y()); 849 GetShelfWidget()->GetWindowBoundsInScreen().y());
847 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 850 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
848 gfx::Screen::GetScreen() 851 display::Screen::GetScreen()
849 ->GetDisplayNearestWindow(root) 852 ->GetDisplayNearestWindow(root)
850 .work_area() 853 .work_area()
851 .bottom()); 854 .bottom());
852 855
853 // Move the mouse to the bottom of the screen. 856 // Move the mouse to the bottom of the screen.
854 generator.MoveMouseTo(0, root->bounds().bottom() - 1); 857 generator.MoveMouseTo(0, root->bounds().bottom() - 1);
855 858
856 // Shelf should be shown again (but it shouldn't have changed the work area). 859 // Shelf should be shown again (but it shouldn't have changed the work area).
857 SetState(shelf, SHELF_AUTO_HIDE); 860 SetState(shelf, SHELF_AUTO_HIDE);
858 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 861 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
859 shelf->LayoutShelf(); 862 shelf->LayoutShelf();
860 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(), 863 EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(),
861 GetShelfWidget()->GetWindowBoundsInScreen().y()); 864 GetShelfWidget()->GetWindowBoundsInScreen().y());
862 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 865 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
863 gfx::Screen::GetScreen() 866 display::Screen::GetScreen()
864 ->GetDisplayNearestWindow(root) 867 ->GetDisplayNearestWindow(root)
865 .work_area() 868 .work_area()
866 .bottom()); 869 .bottom());
867 870
868 // Move mouse back up. 871 // Move mouse back up.
869 generator.MoveMouseTo(0, 0); 872 generator.MoveMouseTo(0, 0);
870 SetState(shelf, SHELF_AUTO_HIDE); 873 SetState(shelf, SHELF_AUTO_HIDE);
871 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 874 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
872 shelf->LayoutShelf(); 875 shelf->LayoutShelf();
873 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, 876 EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 generator.MoveMouseTo(right_edge - 50, y); 924 generator.MoveMouseTo(right_edge - 50, y);
922 UpdateAutoHideStateNow(); 925 UpdateAutoHideStateNow();
923 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 926 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
924 927
925 // Moving the mouse over the light bar (but not to the edge of the screen) 928 // Moving the mouse over the light bar (but not to the edge of the screen)
926 // should show the shelf. 929 // should show the shelf.
927 generator.MoveMouseTo(right_edge - 1, y); 930 generator.MoveMouseTo(right_edge - 1, y);
928 UpdateAutoHideStateNow(); 931 UpdateAutoHideStateNow();
929 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 932 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
930 EXPECT_EQ(right_edge - 1, 933 EXPECT_EQ(right_edge - 1,
931 gfx::Screen::GetScreen()->GetCursorScreenPoint().x()); 934 display::Screen::GetScreen()->GetCursorScreenPoint().x());
932 935
933 // Moving the mouse off the light bar should hide the shelf. 936 // Moving the mouse off the light bar should hide the shelf.
934 generator.MoveMouseTo(right_edge - 50, y); 937 generator.MoveMouseTo(right_edge - 50, y);
935 UpdateAutoHideStateNow(); 938 UpdateAutoHideStateNow();
936 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 939 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
937 940
938 // Moving the mouse to the right edge of the screen crossing the light bar 941 // Moving the mouse to the right edge of the screen crossing the light bar
939 // should show the shelf despite the mouse cursor getting warped to the 942 // should show the shelf despite the mouse cursor getting warped to the
940 // secondary display. 943 // secondary display.
941 generator.MoveMouseTo(right_edge - 1, y); 944 generator.MoveMouseTo(right_edge - 1, y);
942 generator.MoveMouseTo(right_edge, y); 945 generator.MoveMouseTo(right_edge, y);
943 UpdateAutoHideStateNow(); 946 UpdateAutoHideStateNow();
944 EXPECT_NE(right_edge - 1, 947 EXPECT_NE(right_edge - 1,
945 gfx::Screen::GetScreen()->GetCursorScreenPoint().x()); 948 display::Screen::GetScreen()->GetCursorScreenPoint().x());
946 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 949 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
947 950
948 // Hide the shelf. 951 // Hide the shelf.
949 generator.MoveMouseTo(right_edge - 50, y); 952 generator.MoveMouseTo(right_edge - 50, y);
950 UpdateAutoHideStateNow(); 953 UpdateAutoHideStateNow();
951 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); 954 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
952 955
953 // Moving the mouse to the right edge of the screen crossing the light bar and 956 // Moving the mouse to the right edge of the screen crossing the light bar and
954 // overshooting by a lot should keep the shelf hidden. 957 // overshooting by a lot should keep the shelf hidden.
955 generator.MoveMouseTo(right_edge - 1, y); 958 generator.MoveMouseTo(right_edge - 1, y);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1051 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1049 views::Widget* widget = new views::Widget; 1052 views::Widget* widget = new views::Widget;
1050 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 1053 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
1051 params.bounds = gfx::Rect(0, 0, 200, 200); 1054 params.bounds = gfx::Rect(0, 0, 200, 200);
1052 params.context = CurrentContext(); 1055 params.context = CurrentContext();
1053 // Widget is now owned by the parent window. 1056 // Widget is now owned by the parent window.
1054 widget->Init(params); 1057 widget->Init(params);
1055 widget->Show(); 1058 widget->Show();
1056 aura::Window* window = widget->GetNativeWindow(); 1059 aura::Window* window = widget->GetNativeWindow();
1057 gfx::Rect display_bounds( 1060 gfx::Rect display_bounds(
1058 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); 1061 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
1059 1062
1060 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1063 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1061 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 1064 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
1062 1065
1063 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1066 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1064 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1067 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1065 1068
1066 widget->Maximize(); 1069 widget->Maximize();
1067 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1070 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1068 EXPECT_EQ(gfx::Screen::GetScreen() 1071 EXPECT_EQ(display::Screen::GetScreen()
1069 ->GetDisplayNearestWindow(window) 1072 ->GetDisplayNearestWindow(window)
1070 .work_area() 1073 .work_area()
1071 .bottom(), 1074 .bottom(),
1072 widget->GetWorkAreaBoundsInScreen().bottom()); 1075 widget->GetWorkAreaBoundsInScreen().bottom());
1073 1076
1074 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1077 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1075 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 1078 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
1076 EXPECT_EQ(gfx::Screen::GetScreen() 1079 EXPECT_EQ(display::Screen::GetScreen()
1077 ->GetDisplayNearestWindow(window) 1080 ->GetDisplayNearestWindow(window)
1078 .work_area() 1081 .work_area()
1079 .bottom(), 1082 .bottom(),
1080 widget->GetWorkAreaBoundsInScreen().bottom()); 1083 widget->GetWorkAreaBoundsInScreen().bottom());
1081 1084
1082 ui::ScopedAnimationDurationScaleMode animation_duration( 1085 ui::ScopedAnimationDurationScaleMode animation_duration(
1083 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); 1086 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
1084 1087
1085 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1088 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1086 ShelfWidget* shelf_widget = GetShelfWidget(); 1089 ShelfWidget* shelf_widget = GetShelfWidget();
1087 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); 1090 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible());
1088 StepWidgetLayerAnimatorToEnd(shelf_widget); 1091 StepWidgetLayerAnimatorToEnd(shelf_widget);
1089 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); 1092 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
1090 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1093 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1091 EXPECT_EQ(gfx::Screen::GetScreen() 1094 EXPECT_EQ(display::Screen::GetScreen()
1092 ->GetDisplayNearestWindow(window) 1095 ->GetDisplayNearestWindow(window)
1093 .work_area() 1096 .work_area()
1094 .bottom(), 1097 .bottom(),
1095 widget->GetWorkAreaBoundsInScreen().bottom()); 1098 widget->GetWorkAreaBoundsInScreen().bottom());
1096 } 1099 }
1097 1100
1098 // Basic assertions around the dimming of the shelf. 1101 // Basic assertions around the dimming of the shelf.
1099 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { 1102 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) {
1100 // Since ShelfLayoutManager queries for mouse location, move the mouse so 1103 // Since ShelfLayoutManager queries for mouse location, move the mouse so
1101 // it isn't over the shelf. 1104 // it isn't over the shelf.
1102 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1105 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1103 gfx::Point()); 1106 gfx::Point());
1104 generator.MoveMouseTo(0, 0); 1107 generator.MoveMouseTo(0, 0);
1105 1108
1106 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1109 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1107 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); 1110 shelf->shelf_widget()->DisableDimmingAnimationsForTest();
1108 1111
1109 views::Widget* widget = new views::Widget; 1112 views::Widget* widget = new views::Widget;
1110 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 1113 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
1111 params.bounds = gfx::Rect(0, 0, 200, 200); 1114 params.bounds = gfx::Rect(0, 0, 200, 200);
1112 params.context = CurrentContext(); 1115 params.context = CurrentContext();
1113 // Widget is now owned by the parent window. 1116 // Widget is now owned by the parent window.
1114 widget->Init(params); 1117 widget->Init(params);
1115 widget->Show(); 1118 widget->Show();
1116 aura::Window* window = widget->GetNativeWindow(); 1119 aura::Window* window = widget->GetNativeWindow();
1117 gfx::Rect display_bounds( 1120 gfx::Rect display_bounds(
1118 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); 1121 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
1119 1122
1120 gfx::Point off_shelf = display_bounds.CenterPoint(); 1123 gfx::Point off_shelf = display_bounds.CenterPoint();
1121 gfx::Point on_shelf = 1124 gfx::Point on_shelf =
1122 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); 1125 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint();
1123 1126
1124 // Test there is no dimming object active at this point. 1127 // Test there is no dimming object active at this point.
1125 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); 1128 generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
1126 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); 1129 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
1127 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); 1130 generator.MoveMouseTo(off_shelf.x(), off_shelf.y());
1128 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); 1131 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 1242
1240 views::Widget* widget = new views::Widget; 1243 views::Widget* widget = new views::Widget;
1241 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); 1244 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
1242 params.bounds = gfx::Rect(0, 0, 200, 200); 1245 params.bounds = gfx::Rect(0, 0, 200, 200);
1243 params.context = CurrentContext(); 1246 params.context = CurrentContext();
1244 // Widget is now owned by the parent window. 1247 // Widget is now owned by the parent window.
1245 widget->Init(params); 1248 widget->Init(params);
1246 widget->Show(); 1249 widget->Show();
1247 aura::Window* window = widget->GetNativeWindow(); 1250 aura::Window* window = widget->GetNativeWindow();
1248 gfx::Rect display_bounds( 1251 gfx::Rect display_bounds(
1249 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); 1252 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds());
1250 1253
1251 // After maximization, the shelf should be visible and the dimmer created. 1254 // After maximization, the shelf should be visible and the dimmer created.
1252 widget->Maximize(); 1255 widget->Maximize();
1253 1256
1254 gfx::Point off_shelf = display_bounds.CenterPoint(); 1257 gfx::Point off_shelf = display_bounds.CenterPoint();
1255 gfx::Point on_shelf = 1258 gfx::Point on_shelf =
1256 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); 1259 shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint();
1257 1260
1258 // Moving the mouse on the shelf should undim the bar. 1261 // Moving the mouse on the shelf should undim the bar.
1259 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); 1262 generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { 1663 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) {
1661 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1664 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1662 // Force an initial layout. 1665 // Force an initial layout.
1663 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1666 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1664 shelf->LayoutShelf(); 1667 shelf->LayoutShelf();
1665 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1668 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1666 1669
1667 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); 1670 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
1668 gfx::Rect shelf_bounds( 1671 gfx::Rect shelf_bounds(
1669 GetShelfWidget()->GetWindowBoundsInScreen()); 1672 GetShelfWidget()->GetWindowBoundsInScreen());
1670 const gfx::Screen* screen = gfx::Screen::GetScreen(); 1673 const display::Screen* screen = display::Screen::GetScreen();
1671 gfx::Display display = 1674 display::Display display =
1672 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); 1675 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
1673 ASSERT_NE(-1, display.id()); 1676 ASSERT_NE(-1, display.id());
1674 EXPECT_EQ(shelf->GetIdealBounds().width(), 1677 EXPECT_EQ(shelf->GetIdealBounds().width(),
1675 display.GetWorkAreaInsets().left()); 1678 display.GetWorkAreaInsets().left());
1676 EXPECT_GE( 1679 EXPECT_GE(
1677 shelf_bounds.width(), 1680 shelf_bounds.width(),
1678 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); 1681 GetShelfWidget()->GetContentsView()->GetPreferredSize().width());
1679 EXPECT_EQ(wm::SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); 1682 EXPECT_EQ(wm::SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment());
1680 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); 1683 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget();
1681 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); 1684 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen());
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 StatusAreaWidget* status_area_widget = 2294 StatusAreaWidget* status_area_widget =
2292 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); 2295 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget();
2293 EXPECT_TRUE(status_area_widget->IsVisible()); 2296 EXPECT_TRUE(status_area_widget->IsVisible());
2294 // Shelf should be in the first display's area. 2297 // Shelf should be in the first display's area.
2295 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2298 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2296 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2299 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2297 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2300 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2298 } 2301 }
2299 2302
2300 } // namespace ash 2303 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698