blob: f4fdd47637decb5859fd67d6eae8d3fe2def6c3b (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright 2013 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.
#ifndef CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_
#define CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_
#include <string>
#include "base/run_loop.h"
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/instant/instant_model_observer.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_instant_controller.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
#include "chrome/common/search_types.h"
#include "chrome/test/base/in_process_browser_test.h"
class InstantTestModelObserver : public InstantModelObserver {
public:
InstantTestModelObserver(InstantModel* model,
chrome::search::Mode::Type desired_mode_type);
~InstantTestModelObserver();
void WaitUntilDesiredPreviewState();
// Overridden from InstantModelObserver:
virtual void PreviewStateChanged(const InstantModel& model) OVERRIDE;
private:
InstantModel* const model_;
const chrome::search::Mode::Type desired_mode_type_;
base::RunLoop run_loop_;
DISALLOW_COPY_AND_ASSIGN(InstantTestModelObserver);
};
class InstantTestBase : public InProcessBrowserTest {
public:
InstantTestBase()
: https_test_server_(
net::TestServer::TYPE_HTTPS,
net::BaseTestServer::SSLOptions(),
FilePath(FILE_PATH_LITERAL("chrome/test/data"))) {
}
protected:
void SetupInstant();
void SetupInstantUsingTemplateURL();
InstantController* instant() {
return browser()->instant_controller()->instant();
}
OmniboxView* omnibox() {
return browser()->window()->GetLocationBar()->GetLocationEntry();
}
void KillInstantRenderView();
void FocusOmnibox();
void FocusOmniboxAndWaitForInstantSupport();
void SetOmniboxText(const std::string& text);
void SetOmniboxTextAndWaitForInstantToShow(const std::string& text);
bool GetBoolFromJS(content::WebContents* contents,
const std::string& script,
bool* result) WARN_UNUSED_RESULT;
bool GetIntFromJS(content::WebContents* contents,
const std::string& script,
int* result) WARN_UNUSED_RESULT;
bool GetStringFromJS(content::WebContents* contents,
const std::string& script,
std::string* result) WARN_UNUSED_RESULT;
bool ExecuteScript(const std::string& script) WARN_UNUSED_RESULT;
bool CheckVisibilityIs(content::WebContents* contents,
bool expected) WARN_UNUSED_RESULT;
GURL instant_url_;
// HTTPS Testing server, started on demand.
net::TestServer https_test_server_;
};
#endif // CHROME_BROWSER_INSTANT_INSTANT_TEST_UTILS_H_
|