1 // Copyright 2015 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.
5 #include "base/logging.h"
6 #include "content/public/browser/web_ui_message_handler.h"
7 #include "content/public/test/test_web_ui.h"
11 TestWebUI::TestWebUI() : web_contents_(nullptr) {
14 TestWebUI::~TestWebUI() {
18 void TestWebUI::ClearTrackedCalls() {
22 WebContents
* TestWebUI::GetWebContents() const {
26 WebUIController
* TestWebUI::GetController() const {
30 float TestWebUI::GetDeviceScaleFactor() const {
34 const base::string16
& TestWebUI::GetOverriddenTitle() const {
38 ui::PageTransition
TestWebUI::GetLinkTransitionType() const {
39 return ui::PAGE_TRANSITION_LINK
;
42 int TestWebUI::GetBindings() const {
46 void TestWebUI::AddMessageHandler(WebUIMessageHandler
* handler
) {
47 handlers_
.push_back(handler
);
50 void TestWebUI::CallJavascriptFunction(const std::string
& function_name
) {
51 call_data_
.push_back(new CallData(function_name
));
54 void TestWebUI::CallJavascriptFunction(const std::string
& function_name
,
55 const base::Value
& arg1
) {
56 call_data_
.push_back(new CallData(function_name
));
57 call_data_
.back()->TakeAsArg1(arg1
.DeepCopy());
60 void TestWebUI::CallJavascriptFunction(const std::string
& function_name
,
61 const base::Value
& arg1
,
62 const base::Value
& arg2
) {
63 call_data_
.push_back(new CallData(function_name
));
64 call_data_
.back()->TakeAsArg1(arg1
.DeepCopy());
65 call_data_
.back()->TakeAsArg2(arg2
.DeepCopy());
68 void TestWebUI::CallJavascriptFunction(const std::string
& function_name
,
69 const base::Value
& arg1
,
70 const base::Value
& arg2
,
71 const base::Value
& arg3
) {
75 void TestWebUI::CallJavascriptFunction(const std::string
& function_name
,
76 const base::Value
& arg1
,
77 const base::Value
& arg2
,
78 const base::Value
& arg3
,
79 const base::Value
& arg4
) {
83 void TestWebUI::CallJavascriptFunction(
84 const std::string
& function_name
,
85 const std::vector
<const base::Value
*>& args
) {
89 TestWebUI::CallData::CallData(const std::string
& function_name
)
90 : function_name_(function_name
) {
93 TestWebUI::CallData::~CallData() {
96 void TestWebUI::CallData::TakeAsArg1(base::Value
* arg
) {
100 void TestWebUI::CallData::TakeAsArg2(base::Value
* arg
) {
104 } // namespace content