OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 #include "chrome/browser/ui/browser_window.h" | 6 #include "chrome/browser/ui/browser_window.h" |
7 #include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" | 7 #include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" |
8 #include "chrome/common/chrome_notification_types.h" | 8 #include "chrome/common/chrome_notification_types.h" |
9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
11 #include "content/public/browser/notification_types.h" | 11 #include "content/public/browser/notification_types.h" |
12 #include "net/base/mock_host_resolver.h" | 12 #include "net/base/mock_host_resolver.h" |
13 #include "views/widget/widget.h" | 13 #include "views/widget/widget.h" |
14 | 14 |
15 class VirtualKeyboardManagerTest : public InProcessBrowserTest, | 15 class VirtualKeyboardManagerTest : public InProcessBrowserTest, |
16 public content::NotificationObserver { | 16 public content::NotificationObserver { |
17 public: | 17 public: |
18 VirtualKeyboardManagerTest() | 18 VirtualKeyboardManagerTest() |
19 : InProcessBrowserTest(), | 19 : InProcessBrowserTest(), |
20 keyboard_visible_(false) { | 20 keyboard_visible_(false) { |
21 } | 21 } |
22 | 22 |
23 bool keyboard_visible() const { return keyboard_visible_; } | 23 bool keyboard_visible() const { return keyboard_visible_; } |
24 | 24 |
25 void SetupNotificationListener() { | 25 void SetupNotificationListener() { |
26 registrar_.Add(this, | 26 registrar_.Add(this, |
27 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, | 27 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, |
28 NotificationService::AllSources()); | 28 content::NotificationService::AllSources()); |
29 } | 29 } |
30 | 30 |
31 private: | 31 private: |
32 virtual void TearDown() { | 32 virtual void TearDown() { |
33 registrar_.RemoveAll(); | 33 registrar_.RemoveAll(); |
34 InProcessBrowserTest::TearDown(); | 34 InProcessBrowserTest::TearDown(); |
35 } | 35 } |
36 | 36 |
37 virtual void Observe(int type, | 37 virtual void Observe(int type, |
38 const content::NotificationSource& source, | 38 const content::NotificationSource& source, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 ASSERT_TRUE(test_server()->Start()); | 75 ASSERT_TRUE(test_server()->Start()); |
76 GURL base_url = test_server()->GetURL("files/keyboard/"); | 76 GURL base_url = test_server()->GetURL("files/keyboard/"); |
77 | 77 |
78 // Go to a page that gives focus to a textfield onload. | 78 // Go to a page that gives focus to a textfield onload. |
79 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("focus.html")); | 79 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("focus.html")); |
80 EXPECT_TRUE(keyboard_visible()); | 80 EXPECT_TRUE(keyboard_visible()); |
81 | 81 |
82 // Open a new tab that does not give focus to a textfield onload. | 82 // Open a new tab that does not give focus to a textfield onload. |
83 ui_test_utils::WindowedNotificationObserver load_stop_observer( | 83 ui_test_utils::WindowedNotificationObserver load_stop_observer( |
84 content::NOTIFICATION_LOAD_STOP, | 84 content::NOTIFICATION_LOAD_STOP, |
85 NotificationService::AllSources()); | 85 content::NotificationService::AllSources()); |
86 browser()->AddSelectedTabWithURL(base_url.Resolve("blank.html"), | 86 browser()->AddSelectedTabWithURL(base_url.Resolve("blank.html"), |
87 content::PAGE_TRANSITION_LINK); | 87 content::PAGE_TRANSITION_LINK); |
88 load_stop_observer.Wait(); | 88 load_stop_observer.Wait(); |
89 | 89 |
90 // Focus the first tab where the textfield has the focus. | 90 // Focus the first tab where the textfield has the focus. |
91 browser()->SelectNextTab(); | 91 browser()->SelectNextTab(); |
92 EXPECT_TRUE(keyboard_visible()); | 92 EXPECT_TRUE(keyboard_visible()); |
93 | 93 |
94 // Focus the next tab again. | 94 // Focus the next tab again. |
95 browser()->SelectNextTab(); | 95 browser()->SelectNextTab(); |
96 EXPECT_FALSE(keyboard_visible()); | 96 EXPECT_FALSE(keyboard_visible()); |
97 } | 97 } |
OLD | NEW |