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

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 810033010: Remove TransparentActivateWindowButton from Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "ash/accessibility_delegate.h" 7 #include "ash/accessibility_delegate.h"
8 #include "ash/drag_drop/drag_drop_controller.h" 8 #include "ash/drag_drop/drag_drop_controller.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
(...skipping 28 matching lines...) Expand all
39 #include "ui/aura/test/test_window_delegate.h" 39 #include "ui/aura/test/test_window_delegate.h"
40 #include "ui/aura/test/test_windows.h" 40 #include "ui/aura/test/test_windows.h"
41 #include "ui/aura/window.h" 41 #include "ui/aura/window.h"
42 #include "ui/aura/window_event_dispatcher.h" 42 #include "ui/aura/window_event_dispatcher.h"
43 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 43 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
44 #include "ui/events/test/event_generator.h" 44 #include "ui/events/test/event_generator.h"
45 #include "ui/gfx/geometry/point_conversions.h" 45 #include "ui/gfx/geometry/point_conversions.h"
46 #include "ui/gfx/geometry/rect_conversions.h" 46 #include "ui/gfx/geometry/rect_conversions.h"
47 #include "ui/gfx/transform.h" 47 #include "ui/gfx/transform.h"
48 #include "ui/gfx/transform_util.h" 48 #include "ui/gfx/transform_util.h"
49 #include "ui/views/controls/label.h" 49 #include "ui/views/controls/button/label_button.h"
50 #include "ui/views/widget/native_widget_aura.h" 50 #include "ui/views/widget/native_widget_aura.h"
51 #include "ui/views/widget/widget_delegate.h" 51 #include "ui/views/widget/widget_delegate.h"
52 #include "ui/wm/core/window_util.h" 52 #include "ui/wm/core/window_util.h"
53 #include "ui/wm/public/activation_delegate.h" 53 #include "ui/wm/public/activation_delegate.h"
54 54
55 namespace ash { 55 namespace ash {
56 namespace { 56 namespace {
57 57
58 typedef std::vector<aura::Window*> WindowList; 58 typedef std::vector<aura::Window*> WindowList;
59 typedef std::map<const aura::Window*, int> WindowIndexMap; 59 typedef std::map<const aura::Window*, int> WindowIndexMap;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) { 108 aura::Window* CreateNonActivatableWindow(const gfx::Rect& bounds) {
109 aura::Window* window = CreateWindow(bounds); 109 aura::Window* window = CreateWindow(bounds);
110 aura::client::SetActivationDelegate(window, 110 aura::client::SetActivationDelegate(window,
111 &non_activatable_activation_delegate_); 111 &non_activatable_activation_delegate_);
112 EXPECT_FALSE(ash::wm::CanActivateWindow(window)); 112 EXPECT_FALSE(ash::wm::CanActivateWindow(window));
113 return window; 113 return window;
114 } 114 }
115 115
116 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) { 116 aura::Window* CreatePanelWindow(const gfx::Rect& bounds) {
117 aura::Window* window = CreateTestWindowInShellWithDelegateAndType( 117 aura::Window* window = CreateTestWindowInShellWithDelegateAndType(
118 nullptr, ui::wm::WINDOW_TYPE_PANEL, 0, bounds); 118
119
120 &delegate_, ui::wm::WINDOW_TYPE_PANEL, 0, bounds);
119 test::TestShelfDelegate::instance()->AddShelfItem(window); 121 test::TestShelfDelegate::instance()->AddShelfItem(window);
120 shelf_view_test()->RunMessageLoopUntilAnimationsDone(); 122 shelf_view_test()->RunMessageLoopUntilAnimationsDone();
121 return window; 123 return window;
122 } 124 }
123 125
124 views::Widget* CreatePanelWindowWidget(const gfx::Rect& bounds) { 126 views::Widget* CreatePanelWindowWidget(const gfx::Rect& bounds) {
125 views::Widget* widget = new views::Widget; 127 views::Widget* widget = new views::Widget;
126 views::Widget::InitParams params; 128 views::Widget::InitParams params;
127 params.bounds = bounds; 129 params.bounds = bounds;
128 params.type = views::Widget::InitParams::TYPE_PANEL; 130 params.type = views::Widget::InitParams::TYPE_PANEL;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 WindowSelector* ws = ash::Shell::GetInstance()-> 223 WindowSelector* ws = ash::Shell::GetInstance()->
222 window_selector_controller()->window_selector_.get(); 224 window_selector_controller()->window_selector_.get();
223 return ws->text_filter_widget_->GetNativeWindow()->layer()-> 225 return ws->text_filter_widget_->GetNativeWindow()->layer()->
224 GetTargetTransform().IsIdentity(); 226 GetTargetTransform().IsIdentity();
225 } 227 }
226 228
227 views::Widget* GetCloseButton(ash::WindowSelectorItem* window) { 229 views::Widget* GetCloseButton(ash::WindowSelectorItem* window) {
228 return &(window->close_button_widget_); 230 return &(window->close_button_widget_);
229 } 231 }
230 232
231 views::Label* GetLabelView(ash::WindowSelectorItem* window) { 233 views::LabelButton* GetLabelButtonView(ash::WindowSelectorItem* window) {
232 return window->window_label_view_; 234 return window->window_label_button_view_;
233 } 235 }
234 236
235 // Tests that a window is contained within a given WindowSelectorItem, and 237 // Tests that a window is contained within a given WindowSelectorItem, and
236 // that both the window and its matching close button are within the same 238 // that both the window and its matching close button are within the same
237 // screen. 239 // screen.
238 void IsWindowAndCloseButtonInScreen(aura::Window* window, 240 void IsWindowAndCloseButtonInScreen(aura::Window* window,
239 WindowSelectorItem* window_item) { 241 WindowSelectorItem* window_item) {
240 aura::Window* root_window = window_item->root_window(); 242 aura::Window* root_window = window_item->root_window();
241 EXPECT_TRUE(window_item->Contains(window)); 243 EXPECT_TRUE(window_item->Contains(window));
242 EXPECT_TRUE(root_window->GetBoundsInScreen().Contains( 244 EXPECT_TRUE(root_window->GetBoundsInScreen().Contains(
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 370
369 event_generator.ReleaseTouchId(kTouchId); 371 event_generator.ReleaseTouchId(kTouchId);
370 } 372 }
371 373
372 // Tests that we do not crash and a window is selected when appropriate when 374 // Tests that we do not crash and a window is selected when appropriate when
373 // we click on a window during touch. 375 // we click on a window during touch.
374 TEST_F(WindowSelectorTest, ClickOnWindowDuringTouch) { 376 TEST_F(WindowSelectorTest, ClickOnWindowDuringTouch) {
375 gfx::Rect bounds(0, 0, 400, 400); 377 gfx::Rect bounds(0, 0, 400, 400);
376 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); 378 scoped_ptr<aura::Window> window1(CreateWindow(bounds));
377 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); 379 scoped_ptr<aura::Window> window2(CreateWindow(bounds));
378 wm::ActivateWindow(window2.get()); 380 wm::ActivateWindow(window1.get());
379 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); 381 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
380 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 382 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
381 383
382 ToggleOverview(); 384 ToggleOverview();
383 385
384 gfx::Rect window1_bounds = 386 gfx::Rect window1_bounds =
385 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window1.get())); 387 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window1.get()));
386 ui::test::EventGenerator event_generator(window1->GetRootWindow(), 388 ui::test::EventGenerator event_generator(window1->GetRootWindow(),
387 window1_bounds.CenterPoint()); 389 window1_bounds.CenterPoint());
388 390
389 // Clicking on |window2| while touching on |window1| should not cause a 391 // Clicking on |window2| while touching on |window1| should not cause a
390 // crash, and overview mode should remain engaged because |window1| 392 // crash, overview mode should be disengaged and |window2| should be active.
391 // has capture.
392 const int kTouchId = 19; 393 const int kTouchId = 19;
393 event_generator.PressTouchId(kTouchId); 394 event_generator.PressTouchId(kTouchId);
394 event_generator.MoveMouseToCenterOf(window2.get()); 395 event_generator.MoveMouseToCenterOf(window2.get());
395 event_generator.ClickLeftButton(); 396 event_generator.ClickLeftButton();
396 EXPECT_TRUE(IsSelecting()); 397 EXPECT_FALSE(IsSelecting());
398 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
397 event_generator.ReleaseTouchId(kTouchId); 399 event_generator.ReleaseTouchId(kTouchId);
398 400
401 ToggleOverview();
402
399 // Clicking on |window1| while touching on |window1| should not cause 403 // Clicking on |window1| while touching on |window1| should not cause
400 // a crash, overview mode should be disengaged, and |window1| should 404 // a crash, overview mode should be disengaged, and |window1| should
401 // be active. 405 // be active.
402 event_generator.MoveMouseToCenterOf(window1.get()); 406 event_generator.MoveMouseToCenterOf(window1.get());
403 event_generator.PressTouchId(kTouchId); 407 event_generator.PressTouchId(kTouchId);
404 event_generator.ClickLeftButton(); 408 event_generator.ClickLeftButton();
405 EXPECT_FALSE(IsSelecting()); 409 EXPECT_FALSE(IsSelecting());
406 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 410 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
407 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); 411 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
408 event_generator.ReleaseTouchId(kTouchId); 412 event_generator.ReleaseTouchId(kTouchId);
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 RunAllPendingInMessageLoop(); 927 RunAllPendingInMessageLoop();
924 } 928 }
925 929
926 // Test that a label is created under the window on entering overview mode. 930 // Test that a label is created under the window on entering overview mode.
927 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { 931 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) {
928 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); 932 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100)));
929 base::string16 window_title = base::UTF8ToUTF16("My window"); 933 base::string16 window_title = base::UTF8ToUTF16("My window");
930 window->SetTitle(window_title); 934 window->SetTitle(window_title);
931 ToggleOverview(); 935 ToggleOverview();
932 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); 936 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back();
933 views::Label* label = GetLabelView(window_item); 937 views::LabelButton* label = GetLabelButtonView(window_item);
934 // Has the label view been created? 938 // Has the label view been created?
935 ASSERT_TRUE(label); 939 ASSERT_TRUE(label);
936 940
937 // Verify the label matches the window title. 941 // Verify the label matches the window title.
938 EXPECT_EQ(label->text(), window_title); 942 EXPECT_EQ(label->GetText(), window_title);
939 943
940 // Update the window title and check that the label is updated, too. 944 // Update the window title and check that the label is updated, too.
941 base::string16 updated_title = base::UTF8ToUTF16("Updated title"); 945 base::string16 updated_title = base::UTF8ToUTF16("Updated title");
942 window->SetTitle(updated_title); 946 window->SetTitle(updated_title);
943 EXPECT_EQ(label->text(), updated_title); 947 EXPECT_EQ(label->GetText(), updated_title);
944 948
945 // Labels are located based on target_bounds, not the actual window item 949 // Labels are located based on target_bounds, not the actual window item
946 // bounds. 950 // bounds.
947 gfx::Rect target_bounds(window_item->target_bounds()); 951 gfx::Rect target_bounds(window_item->target_bounds());
948 gfx::Rect expected_label_bounds(target_bounds.x(), 952 gfx::Rect expected_label_bounds(target_bounds.x(),
949 target_bounds.bottom() - label-> 953 target_bounds.bottom() - label->
950 GetPreferredSize().height(), 954 GetPreferredSize().height(),
951 target_bounds.width(), 955 target_bounds.width(),
952 label->GetPreferredSize().height()); 956 label->GetPreferredSize().height());
953 gfx::Rect real_label_bounds = label->GetWidget()->GetNativeWindow()->bounds(); 957 gfx::Rect real_label_bounds = label->GetWidget()->GetNativeWindow()->bounds();
954 EXPECT_EQ(real_label_bounds, expected_label_bounds); 958 EXPECT_EQ(real_label_bounds, expected_label_bounds);
955 } 959 }
956 960
957 // Tests that a label is created for the active panel in a group of panels in 961 // Tests that a label is created for the active panel in a group of panels in
958 // overview mode. 962 // overview mode.
959 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) { 963 TEST_F(WindowSelectorTest, CreateLabelUnderPanel) {
960 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); 964 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
961 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); 965 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
962 base::string16 panel1_title = base::UTF8ToUTF16("My panel"); 966 base::string16 panel1_title = base::UTF8ToUTF16("My panel");
963 base::string16 panel2_title = base::UTF8ToUTF16("Another panel"); 967 base::string16 panel2_title = base::UTF8ToUTF16("Another panel");
964 base::string16 updated_panel1_title = base::UTF8ToUTF16("WebDriver Torso"); 968 base::string16 updated_panel1_title = base::UTF8ToUTF16("WebDriver Torso");
965 base::string16 updated_panel2_title = base::UTF8ToUTF16("Da panel"); 969 base::string16 updated_panel2_title = base::UTF8ToUTF16("Da panel");
966 panel1->SetTitle(panel1_title); 970 panel1->SetTitle(panel1_title);
967 panel2->SetTitle(panel2_title); 971 panel2->SetTitle(panel2_title);
968 wm::ActivateWindow(panel1.get()); 972 wm::ActivateWindow(panel1.get());
969 ToggleOverview(); 973 ToggleOverview();
970 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); 974 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back();
971 views::Label* label = GetLabelView(window_item); 975 views::LabelButton* label = GetLabelButtonView(window_item);
972 // Has the label view been created? 976 // Has the label view been created?
973 ASSERT_TRUE(label); 977 ASSERT_TRUE(label);
974 978
975 // Verify the label matches the active window title. 979 // Verify the label matches the active window title.
976 EXPECT_EQ(label->text(), panel1_title); 980 EXPECT_EQ(label->GetText(), panel1_title);
977 // Verify that updating the title also updates the label. 981 // Verify that updating the title also updates the label.
978 panel1->SetTitle(updated_panel1_title); 982 panel1->SetTitle(updated_panel1_title);
979 EXPECT_EQ(label->text(), updated_panel1_title); 983 EXPECT_EQ(label->GetText(), updated_panel1_title);
980 // After destroying the first panel, the label should match the second panel. 984 // After destroying the first panel, the label should match the second panel.
981 panel1.reset(); 985 panel1.reset();
982 label = GetLabelView(window_item); 986 label = GetLabelButtonView(window_item);
983 EXPECT_EQ(label->text(), panel2_title); 987 EXPECT_EQ(label->GetText(), panel2_title);
984 // Also test updating the title on the second panel. 988 // Also test updating the title on the second panel.
985 panel2->SetTitle(updated_panel2_title); 989 panel2->SetTitle(updated_panel2_title);
986 EXPECT_EQ(label->text(), updated_panel2_title); 990 EXPECT_EQ(label->GetText(), updated_panel2_title);
987 } 991 }
988 992
989 // Tests that overview updates the window positions if the display orientation 993 // Tests that overview updates the window positions if the display orientation
990 // changes. 994 // changes.
991 TEST_F(WindowSelectorTest, DisplayOrientationChanged) { 995 TEST_F(WindowSelectorTest, DisplayOrientationChanged) {
992 if (!SupportsHostWindowResize()) 996 if (!SupportsHostWindowResize())
993 return; 997 return;
994 998
995 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); 999 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
996 UpdateDisplay("600x200"); 1000 UpdateDisplay("600x200");
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 event_generator1.ClickLeftButton(); 1194 event_generator1.ClickLeftButton();
1191 EXPECT_TRUE(widget1->IsClosed()); 1195 EXPECT_TRUE(widget1->IsClosed());
1192 RunAllPendingInMessageLoop(); 1196 RunAllPendingInMessageLoop();
1193 EXPECT_TRUE(IsSelecting()); 1197 EXPECT_TRUE(IsSelecting());
1194 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).front(); 1198 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).front();
1195 EXPECT_FALSE(window_item->empty()); 1199 EXPECT_FALSE(window_item->empty());
1196 EXPECT_TRUE(window_item->Contains(window2)); 1200 EXPECT_TRUE(window_item->Contains(window2));
1197 EXPECT_TRUE(GetCloseButton(window_item)->IsVisible()); 1201 EXPECT_TRUE(GetCloseButton(window_item)->IsVisible());
1198 1202
1199 1203
1200 views::Label* label = GetLabelView(window_item); 1204 views::LabelButton* label = GetLabelButtonView(window_item);
1201 EXPECT_EQ(label->text(), panel2_title); 1205 EXPECT_EQ(label->GetText(), panel2_title);
1202 1206
1203 gfx::RectF bounds2 = GetTransformedBoundsInRootWindow(window2); 1207 gfx::RectF bounds2 = GetTransformedBoundsInRootWindow(window2);
1204 gfx::Point point2(bounds2.top_right().x() - 1, bounds2.top_right().y() - 1); 1208 gfx::Point point2(bounds2.top_right().x() - 1, bounds2.top_right().y() - 1);
1205 ui::test::EventGenerator event_generator2(window2->GetRootWindow(), point2); 1209 ui::test::EventGenerator event_generator2(window2->GetRootWindow(), point2);
1206 1210
1207 EXPECT_FALSE(widget2->IsClosed()); 1211 EXPECT_FALSE(widget2->IsClosed());
1208 event_generator2.ClickLeftButton(); 1212 event_generator2.ClickLeftButton();
1209 EXPECT_TRUE(widget2->IsClosed()); 1213 EXPECT_TRUE(widget2->IsClosed());
1210 RunAllPendingInMessageLoop(); 1214 RunAllPendingInMessageLoop();
1211 EXPECT_FALSE(IsSelecting()); 1215 EXPECT_FALSE(IsSelecting());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 1346
1343 // Switch to overview mode. 1347 // Switch to overview mode.
1344 ToggleOverview(); 1348 ToggleOverview();
1345 ASSERT_TRUE(IsSelecting()); 1349 ASSERT_TRUE(IsSelecting());
1346 1350
1347 // Tap should now exit overview mode. 1351 // Tap should now exit overview mode.
1348 generator.GestureTapAt(point_in_background_page); 1352 generator.GestureTapAt(point_in_background_page);
1349 EXPECT_FALSE(IsSelecting()); 1353 EXPECT_FALSE(IsSelecting());
1350 } 1354 }
1351 1355
1352 // Tests that the transparent overlays z-order matches the windows z-order.
Nina 2015/01/09 15:43:48 This test is no longer needed as we are actually t
1353 TEST_F(WindowSelectorTest, PanelStackOrdering) {
1354 gfx::Rect bounds1(0, 0, 100, 100);
1355 gfx::Rect bounds2(10, 0, 100, 100);
1356 gfx::Rect bounds3(20, 0, 100, 100);
1357 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds1));
1358 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds2));
1359 scoped_ptr<aura::Window> panel3(CreatePanelWindow(bounds3));
1360
1361 wm::ActivateWindow(panel2.get());
1362 wm::ActivateWindow(panel3.get());
1363 wm::ActivateWindow(panel1.get());
1364
1365 WindowIndexMap z_order;
1366 GetWindowIndexMap(panel1->parent()->children(), &z_order);
1367 ASSERT_GT(z_order[panel1.get()], z_order[panel2.get()]);
1368 ASSERT_GT(z_order[panel2.get()], z_order[panel3.get()]);
1369
1370 WindowList mru_windows = ash::Shell::GetInstance()->mru_window_tracker()->
1371 BuildMruWindowList();
1372 WindowIndexMap mru_rank;
1373 GetWindowIndexMap(mru_windows, &mru_rank);
1374 ASSERT_LT(mru_rank[panel1.get()], mru_rank[panel3.get()]);
1375 ASSERT_LT(mru_rank[panel3.get()], mru_rank[panel2.get()]);
1376
1377 ToggleOverview();
1378
1379 gfx::Rect panel1_transformed_bounds(
1380 gfx::ToEnclosingRect(GetTransformedTargetBounds(panel1.get())));
1381 gfx::Rect panel2_transformed_bounds(
1382 gfx::ToEnclosingRect(GetTransformedTargetBounds(panel2.get())));
1383 gfx::Rect panel3_transformed_bounds(
1384 gfx::ToEnclosingRect(GetTransformedTargetBounds(panel3.get())));
1385
1386 gfx::Rect target_rect(panel2_transformed_bounds);
1387 target_rect.Intersect(panel3_transformed_bounds);
1388 target_rect.Subtract(panel1_transformed_bounds);
1389 gfx::Point tap_target(target_rect.CenterPoint());
1390
1391 ASSERT_TRUE(panel3_transformed_bounds.Contains(tap_target));
1392
1393 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1394 generator.GestureTapAt(tap_target);
1395 EXPECT_EQ(panel2.get(), GetFocusedWindow());
1396 }
1397
1398 // Tests that individual panels can be selected on a secondary display. 1356 // Tests that individual panels can be selected on a secondary display.
1399 TEST_F(WindowSelectorTest, PanelSelectionOnSecondaryDisplay) { 1357 TEST_F(WindowSelectorTest, PanelSelectionOnSecondaryDisplay) {
1400 if (!SupportsMultipleDisplays()) 1358 if (!SupportsMultipleDisplays())
1401 return; 1359 return;
1402 1360
1403 UpdateDisplay("600x400,600x400"); 1361 UpdateDisplay("600x400,600x400");
1404 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1405 1362
1406 gfx::Rect bounds1(700, 0, 100, 100); 1363 gfx::Rect bounds1(700, 0, 100, 100);
1407 gfx::Rect bounds2(710, 0, 100, 100); 1364 gfx::Rect bounds2(710, 0, 100, 100);
1408 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds1)); 1365 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds1));
1409 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds2)); 1366 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds2));
1410 1367
1411 wm::ActivateWindow(panel2.get()); 1368 wm::ActivateWindow(panel2.get());
1412 wm::ActivateWindow(panel1.get()); 1369 wm::ActivateWindow(panel1.get());
1413 1370
1414 WindowList mru_windows = ash::Shell::GetInstance()->mru_window_tracker()-> 1371 WindowList mru_windows = ash::Shell::GetInstance()->mru_window_tracker()->
1415 BuildMruWindowList(); 1372 BuildMruWindowList();
1416 WindowIndexMap mru_rank; 1373 WindowIndexMap mru_rank;
1417 GetWindowIndexMap(mru_windows, &mru_rank); 1374 GetWindowIndexMap(mru_windows, &mru_rank);
1418 ASSERT_LT(mru_rank[panel1.get()], mru_rank[panel2.get()]); 1375 ASSERT_LT(mru_rank[panel1.get()], mru_rank[panel2.get()]);
1419 ASSERT_EQ(panel1.get(), GetFocusedWindow()); 1376 ASSERT_EQ(panel1.get(), GetFocusedWindow());
1420 1377
1421 ToggleOverview(); 1378 ToggleOverview();
1422 1379
1423 gfx::Rect panel2_transformed_bounds( 1380 gfx::Rect panel2_transformed_bounds(
1424 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(panel2.get()))); 1381 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(panel2.get())));
1425 gfx::Point tap_target(panel2_transformed_bounds.right() - 2, 1382 gfx::Point tap_target(panel2_transformed_bounds.right() - 2,
1426 panel2_transformed_bounds.bottom() - 2); 1383 panel2_transformed_bounds.bottom() - 2);
1427 1384
1428 ui::test::EventGenerator generator(root_windows[1]); 1385 ui::test::EventGenerator generator(panel2->GetRootWindow());
1429 generator.GestureTapAt(tap_target); 1386 generator.GestureTapAt(tap_target);
1430 EXPECT_EQ(panel2.get(), GetFocusedWindow()); 1387 EXPECT_EQ(panel2.get(), GetFocusedWindow());
1431 } 1388 }
1432 1389
1433 } // namespace ash 1390 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698