blob: 5015edc0047d4a62becb7bfbe59fd23b3a510596 (
plain)
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
|
// Copyright (c) 2012 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/ui/views/search_view_controller.h"
#include "base/command_line.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/search/search.h"
#include "chrome/browser/ui/search/search_model.h"
#include "chrome/browser/ui/search/search_types.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
// Currently, the features under test are only enabled under Aura.
#if defined(USE_AURA)
#define MAYBE(x) x
#else
#define MAYBE(x) DISABLED_##x
#endif
// Avoid tests on branded Chrome where channel is set to CHANNEL_STABLE.
#define AVOID_TEST_ON_BRANDED_CHROME() { \
if (!chrome::search::IsInstantExtendedAPIEnabled(browser()->profile())) \
return; \
}
class SearchViewControllerTest : public InProcessBrowserTest {
public:
SearchViewControllerTest() {}
virtual ~SearchViewControllerTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(switches::kEnableInstantExtendedAPI);
}
SearchViewController* controller() {
#if defined(USE_AURA)
const BrowserView* browser_view =
static_cast<BrowserView*>(browser()->window());
return browser_view->search_view_controller();
#else
return NULL;
#endif // USE_AURA
}
bool controller_state_is_ntp() {
return controller()->state() == SearchViewController::STATE_NTP;
}
private:
DISALLOW_COPY_AND_ASSIGN(SearchViewControllerTest);
};
IN_PROC_BROWSER_TEST_F(SearchViewControllerTest, MAYBE(StartToNTP)) {
AVOID_TEST_ON_BRANDED_CHROME();
// Initial state.
EXPECT_TRUE(browser()->search_model()->mode().is_default());
ASSERT_NE(static_cast<SearchViewController*>(NULL), controller());
AddTabAtIndex(0, GURL("chrome://newtab"), content::PAGE_TRANSITION_LINK);
EXPECT_TRUE(browser()->search_model()->mode().is_ntp());
EXPECT_TRUE(controller_state_is_ntp());
}
|