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/touch/keyboard/keyboard_manager.h" | 6 #include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" |
7 #include "chrome/common/chrome_notification_types.h" | 7 #include "chrome/common/chrome_notification_types.h" |
8 #include "chrome/test/base/in_process_browser_test.h" | 8 #include "chrome/test/base/in_process_browser_test.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
10 #include "content/common/content_notification_types.h" | 10 #include "content/common/content_notification_types.h" |
11 #include "net/base/mock_host_resolver.h" | 11 #include "net/base/mock_host_resolver.h" |
12 #include "views/widget/widget.h" | 12 #include "views/widget/widget.h" |
13 | 13 |
14 class KeyboardManagerTest : public InProcessBrowserTest, | 14 class VirtualKeyboardManagerTest : public InProcessBrowserTest, |
15 public NotificationObserver { | 15 public NotificationObserver { |
16 public: | 16 public: |
17 KeyboardManagerTest() | 17 VirtualKeyboardManagerTest() |
18 : InProcessBrowserTest(), | 18 : InProcessBrowserTest(), |
19 keyboard_visible_(false) { | 19 keyboard_visible_(false) { |
20 } | 20 } |
21 | 21 |
22 bool keyboard_visible() const { return keyboard_visible_; } | 22 bool keyboard_visible() const { return keyboard_visible_; } |
23 | 23 |
24 void SetupNotificationListener() { | 24 void SetupNotificationListener() { |
25 registrar_.Add(this, | 25 registrar_.Add(this, |
26 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, | 26 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, |
27 NotificationService::AllSources()); | 27 NotificationService::AllSources()); |
28 } | 28 } |
29 | 29 |
30 private: | 30 private: |
31 virtual void TearDown() { | 31 virtual void TearDown() { |
32 registrar_.RemoveAll(); | 32 registrar_.RemoveAll(); |
33 InProcessBrowserTest::TearDown(); | 33 InProcessBrowserTest::TearDown(); |
34 } | 34 } |
35 | 35 |
36 virtual void Observe(int type, | 36 virtual void Observe(int type, |
37 const NotificationSource& source, | 37 const NotificationSource& source, |
38 const NotificationDetails& details) OVERRIDE { | 38 const NotificationDetails& details) OVERRIDE { |
39 DCHECK_EQ(chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, type); | 39 DCHECK_EQ(chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, type); |
40 keyboard_visible_ = *Details<bool>(details).ptr(); | 40 keyboard_visible_ = *Details<bool>(details).ptr(); |
41 } | 41 } |
42 | 42 |
43 bool keyboard_visible_; | 43 bool keyboard_visible_; |
44 NotificationRegistrar registrar_; | 44 NotificationRegistrar registrar_; |
45 }; | 45 }; |
46 | 46 |
47 IN_PROC_BROWSER_TEST_F(KeyboardManagerTest, TestVisibility) { | 47 IN_PROC_BROWSER_TEST_F(VirtualKeyboardManagerTest, TestVisibility) { |
48 SetupNotificationListener(); | 48 SetupNotificationListener(); |
49 | 49 |
50 // Move focus between the omnibox and the wrench menu a few times. Note that | 50 // Move focus between the omnibox and the wrench menu a few times. Note that |
51 // it is necessary to RunAllPendingInMessageLoop each time after moving | 51 // it is necessary to RunAllPendingInMessageLoop each time after moving |
52 // focus between the omnibox and the wrench menu because of the task posted in | 52 // focus between the omnibox and the wrench menu because of the task posted in |
53 // AccessiblePaneView::FocusWillChange | 53 // AccessiblePaneView::FocusWillChange |
54 | 54 |
55 browser()->FocusAppMenu(); | 55 browser()->FocusAppMenu(); |
56 EXPECT_FALSE(keyboard_visible()); | 56 EXPECT_FALSE(keyboard_visible()); |
57 ui_test_utils::RunAllPendingInMessageLoop(); | 57 ui_test_utils::RunAllPendingInMessageLoop(); |
(...skipping 25 matching lines...) Expand all Loading... |
83 ui_test_utils::WaitForNotification(content::NOTIFICATION_LOAD_STOP); | 83 ui_test_utils::WaitForNotification(content::NOTIFICATION_LOAD_STOP); |
84 | 84 |
85 // Focus the first tab where the textfield has the focus. | 85 // Focus the first tab where the textfield has the focus. |
86 browser()->SelectNextTab(); | 86 browser()->SelectNextTab(); |
87 EXPECT_TRUE(keyboard_visible()); | 87 EXPECT_TRUE(keyboard_visible()); |
88 | 88 |
89 // Focus the next tab again. | 89 // Focus the next tab again. |
90 browser()->SelectNextTab(); | 90 browser()->SelectNextTab(); |
91 EXPECT_FALSE(keyboard_visible()); | 91 EXPECT_FALSE(keyboard_visible()); |
92 } | 92 } |
OLD | NEW |