OLD | NEW |
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/wm/caption_buttons/frame_maximize_button.h" | 5 #include "ash/wm/caption_buttons/frame_maximize_button.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" | 10 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // Move the mouse cursor over the button to bring up the maximizer bubble. | 528 // Move the mouse cursor over the button to bring up the maximizer bubble. |
529 generator.MoveMouseTo(button_pos); | 529 generator.MoveMouseTo(button_pos); |
530 EXPECT_TRUE(maximize_button->maximizer()); | 530 EXPECT_TRUE(maximize_button->maximizer()); |
531 | 531 |
532 // Check that the focused window is still the same. | 532 // Check that the focused window is still the same. |
533 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow()); | 533 EXPECT_EQ(active, aura::client::GetFocusClient(window)->GetFocusedWindow()); |
534 } | 534 } |
535 | 535 |
536 TEST_F(FrameMaximizeButtonTest, MaximizeTap) { | 536 TEST_F(FrameMaximizeButtonTest, MaximizeTap) { |
537 aura::Window* window = widget()->GetNativeWindow(); | 537 aura::Window* window = widget()->GetNativeWindow(); |
538 aura::RootWindow* root_window = window->GetRootWindow(); | 538 aura::Window* root_window = window->GetRootWindow(); |
539 ash::FrameMaximizeButton* maximize_button = | 539 ash::FrameMaximizeButton* maximize_button = |
540 FrameMaximizeButtonTest::maximize_button(); | 540 FrameMaximizeButtonTest::maximize_button(); |
541 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); | 541 gfx::Point button_pos = maximize_button->GetBoundsInScreen().CenterPoint(); |
542 | 542 |
543 const int touch_default_radius = | 543 const int touch_default_radius = |
544 ui::GestureConfiguration::default_radius(); | 544 ui::GestureConfiguration::default_radius(); |
545 ui::GestureConfiguration::set_default_radius(0); | 545 ui::GestureConfiguration::set_default_radius(0); |
546 | 546 |
| 547 aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
547 const int kTouchId = 2; | 548 const int kTouchId = 2; |
548 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, | 549 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, |
549 button_pos, | 550 button_pos, |
550 kTouchId, | 551 kTouchId, |
551 ui::EventTimeForNow()); | 552 ui::EventTimeForNow()); |
552 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); | 553 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&press); |
553 | 554 |
554 button_pos.Offset(9, 8); | 555 button_pos.Offset(9, 8); |
555 ui::TouchEvent release( | 556 ui::TouchEvent release( |
556 ui::ET_TOUCH_RELEASED, | 557 ui::ET_TOUCH_RELEASED, |
557 button_pos, | 558 button_pos, |
558 kTouchId, | 559 kTouchId, |
559 press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); | 560 press.time_stamp() + base::TimeDelta::FromMilliseconds(50)); |
560 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); | 561 dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&release); |
561 | 562 |
562 ui::GestureConfiguration::set_default_radius(touch_default_radius); | 563 ui::GestureConfiguration::set_default_radius(touch_default_radius); |
563 } | 564 } |
564 | 565 |
565 // Test that only the left button will activate the maximize button. | 566 // Test that only the left button will activate the maximize button. |
566 TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) { | 567 TEST_F(FrameMaximizeButtonTest, OnlyLeftButtonMaximizes) { |
567 aura::Window* window = widget()->GetNativeWindow(); | 568 aura::Window* window = widget()->GetNativeWindow(); |
568 ash::FrameMaximizeButton* maximize_button = | 569 ash::FrameMaximizeButton* maximize_button = |
569 FrameMaximizeButtonTest::maximize_button(); | 570 FrameMaximizeButtonTest::maximize_button(); |
570 maximize_button->set_bubble_appearance_delay_ms(0); | 571 maximize_button->set_bubble_appearance_delay_ms(0); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 | 861 |
861 // Test that we have properly reset the state of the now inactive window. | 862 // Test that we have properly reset the state of the now inactive window. |
862 EXPECT_FALSE(maximize_button->maximizer()); | 863 EXPECT_FALSE(maximize_button->maximizer()); |
863 EXPECT_FALSE(maximize_button->phantom_window_open()); | 864 EXPECT_FALSE(maximize_button->phantom_window_open()); |
864 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); | 865 EXPECT_TRUE(wm::GetWindowState(window)->IsNormalShowState()); |
865 EXPECT_EQ(initial_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 866 EXPECT_EQ(initial_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
866 } | 867 } |
867 | 868 |
868 } // namespace test | 869 } // namespace test |
869 } // namespace ash | 870 } // namespace ash |
OLD | NEW |