1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/automation/ui_controls.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/compact_location_bar_host.h"
#include "chrome/browser/chromeos/frame/browser_view.h"
#include "chrome/browser/chromeos/view_ids.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "views/widget/widget.h"
#include "views/window/window.h"
namespace chromeos {
class CompactLocationBarHostTest : public InProcessBrowserTest {
public:
CompactLocationBarHostTest() {
}
virtual void SetUp() {
// Don't animate during the test.
DropdownBarHost::disable_animations_during_testing_ = true;
InProcessBrowserTest::SetUp();
}
BrowserView* browser_view() const {
return static_cast<BrowserView*>(browser()->window());
}
gfx::NativeWindow window() const {
return browser_view()->GetNativeHandle();
}
CompactLocationBarHost* clb_host() const {
return browser_view()->compact_location_bar_host();
}
bool IsViewIdVisible(int id) const {
return browser_view()->GetViewByID(id)->IsVisible();
}
bool IsCurrentTabIndex(int index) {
return clb_host()->IsCurrentTabIndex(index);
}
private:
DISALLOW_COPY_AND_ASSIGN(CompactLocationBarHostTest);
};
IN_PROC_BROWSER_TEST_F(CompactLocationBarHostTest, TestCtrlLOpen) {
// ctrl-l should not open compact location bar in normal mode.
ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false);
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_TRUE(IsCurrentTabIndex(-1));
EXPECT_FALSE(clb_host()->IsVisible());
browser()->ToggleCompactNavigationBar();
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_TRUE(IsCurrentTabIndex(-1));
EXPECT_FALSE(clb_host()->IsVisible());
// ctrl-l should not open compact location bar in compact nav mode.
ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false);
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_TRUE(IsCurrentTabIndex(0));
EXPECT_TRUE(clb_host()->IsVisible());
// Esc to close it.
ui_controls::SendKeyPress(window(), base::VKEY_ESCAPE,
false, false, false, false);
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_TRUE(IsCurrentTabIndex(0));
EXPECT_FALSE(clb_host()->IsVisible());
}
IN_PROC_BROWSER_TEST_F(CompactLocationBarHostTest, TestOnNewTab) {
browser()->ToggleCompactNavigationBar();
ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false);
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_TRUE(IsCurrentTabIndex(0));
EXPECT_TRUE(clb_host()->IsVisible());
browser()->NewTab();
ui_test_utils::RunAllPendingInMessageLoop();
// See http://crbug.com/39858 for details.
//EXPECT_FALSE(clb_host()->IsVisible());
ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false);
ui_test_utils::RunAllPendingInMessageLoop();
EXPECT_TRUE(IsCurrentTabIndex(1));
EXPECT_TRUE(clb_host()->IsVisible());
}
} // namespace chromeos
|