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

Side by Side Diff: chrome/browser/ui/touch/keyboard/keyboard_manager_browsertest.cc

Issue 8044018: Move chrome/browser/ui/touch/keyboard* to chrome/browser/ui/virtual_keyboard/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merged ToT Created 9 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/browser.h"
6 #include "chrome/browser/ui/touch/keyboard/keyboard_manager.h"
7 #include "chrome/common/chrome_notification_types.h"
8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "chrome/test/base/ui_test_utils.h"
10 #include "content/common/content_notification_types.h"
11 #include "net/base/mock_host_resolver.h"
12 #include "views/widget/widget.h"
13
14 class KeyboardManagerTest : public InProcessBrowserTest,
15 public NotificationObserver {
16 public:
17 KeyboardManagerTest()
18 : InProcessBrowserTest(),
19 keyboard_visible_(false) {
20 }
21
22 bool keyboard_visible() const { return keyboard_visible_; }
23
24 void SetupNotificationListener() {
25 registrar_.Add(this,
26 chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED,
27 NotificationService::AllSources());
28 }
29
30 private:
31 virtual void TearDown() {
32 registrar_.RemoveAll();
33 InProcessBrowserTest::TearDown();
34 }
35
36 virtual void Observe(int type,
37 const NotificationSource& source,
38 const NotificationDetails& details) OVERRIDE {
39 DCHECK_EQ(chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, type);
40 keyboard_visible_ = *Details<bool>(details).ptr();
41 }
42
43 bool keyboard_visible_;
44 NotificationRegistrar registrar_;
45 };
46
47 IN_PROC_BROWSER_TEST_F(KeyboardManagerTest, TestVisibility) {
48 SetupNotificationListener();
49
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
52 // focus between the omnibox and the wrench menu because of the task posted in
53 // AccessiblePaneView::FocusWillChange
54
55 browser()->FocusAppMenu();
56 EXPECT_FALSE(keyboard_visible());
57 ui_test_utils::RunAllPendingInMessageLoop();
58
59 browser()->FocusLocationBar();
60 EXPECT_TRUE(keyboard_visible());
61 ui_test_utils::RunAllPendingInMessageLoop();
62
63 browser()->FocusAppMenu();
64 EXPECT_FALSE(keyboard_visible());
65 ui_test_utils::RunAllPendingInMessageLoop();
66
67 browser()->FocusLocationBar();
68 EXPECT_TRUE(keyboard_visible());
69 ui_test_utils::RunAllPendingInMessageLoop();
70
71 // Test with some tabs now
72 host_resolver()->AddRule("*", "127.0.0.1");
73 ASSERT_TRUE(test_server()->Start());
74 GURL base_url = test_server()->GetURL("files/keyboard/");
75
76 // Go to a page that gives focus to a textfield onload.
77 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("focus.html"));
78 EXPECT_TRUE(keyboard_visible());
79
80 // Open a new tab that does not give focus to a textfield onload.
81 browser()->AddSelectedTabWithURL(base_url.Resolve("blank.html"),
82 PageTransition::LINK);
83 ui_test_utils::WaitForNotification(content::NOTIFICATION_LOAD_STOP);
84
85 // Focus the first tab where the textfield has the focus.
86 browser()->SelectNextTab();
87 EXPECT_TRUE(keyboard_visible());
88
89 // Focus the next tab again.
90 browser()->SelectNextTab();
91 EXPECT_FALSE(keyboard_visible());
92 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/touch/keyboard/keyboard_manager.cc ('k') | chrome/browser/ui/touch/status_bubble_touch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698