OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/chromeos/login/ui/login_web_dialog.h" | 5 #include "chrome/browser/chromeos/login/ui/login_web_dialog.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
11 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 11 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
12 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/wm/public/activation_client.h" | 14 #include "ui/events/test/event_generator.h" |
| 15 #include "ui/views/test/widget_test.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 | 18 |
18 typedef InProcessBrowserTest LoginWebDialogTest; | 19 using LoginWebDialogTest = InProcessBrowserTest; |
19 | 20 |
20 // Test that LoginWebDialog is not minimizable. | 21 // Tests that LoginWebDialog is not minimizable. |
21 IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CannotMinimize) { | 22 IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CannotMinimize) { |
22 LoginWebDialog* dialog = new LoginWebDialog( | 23 LoginWebDialog* dialog = new LoginWebDialog( |
23 browser()->profile(), nullptr, nullptr, base::string16(), GURL()); | 24 browser()->profile(), nullptr, nullptr, base::string16(), GURL()); |
24 dialog->Show(); | 25 dialog->Show(); |
25 | 26 aura::Window* window = dialog->get_dialog_window_for_test(); |
26 aura::client::ActivationClient* activation_client = | |
27 aura::client::GetActivationClient( | |
28 ash::Shell::Get()->GetPrimaryRootWindow()); | |
29 aura::Window* window = activation_client->GetActiveWindow(); | |
30 ASSERT_TRUE(window); | 27 ASSERT_TRUE(window); |
31 EXPECT_EQ(0, window->GetProperty(aura::client::kResizeBehaviorKey) & | 28 EXPECT_EQ(0, window->GetProperty(aura::client::kResizeBehaviorKey) & |
32 ui::mojom::kResizeBehaviorCanMinimize); | 29 ui::mojom::kResizeBehaviorCanMinimize); |
33 } | 30 } |
34 | 31 |
| 32 // Tests that LoginWebDialog can be closed by 'Shift + BrowserBack' accelerator. |
| 33 IN_PROC_BROWSER_TEST_F(LoginWebDialogTest, CloseDialogByAccelerator) { |
| 34 LoginWebDialog* dialog = new LoginWebDialog( |
| 35 browser()->profile(), nullptr, nullptr, base::string16(), GURL()); |
| 36 dialog->Show(); |
| 37 gfx::NativeWindow window = dialog->get_dialog_window_for_test(); |
| 38 ASSERT_TRUE(window); |
| 39 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
| 40 views::test::WidgetClosingObserver closing_observer(widget); |
| 41 ui::test::EventGenerator generator(ash::Shell::GetPrimaryRootWindow()); |
| 42 generator.PressKey(ui::VKEY_BROWSER_BACK, ui::EF_SHIFT_DOWN); |
| 43 closing_observer.Wait(); |
| 44 EXPECT_TRUE(closing_observer.widget_closed()); |
| 45 } |
| 46 |
35 } // namespace chromeos | 47 } // namespace chromeos |
OLD | NEW |