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 #ifndef CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_
6 #define CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/values.h"
13 #include "content/public/browser/web_ui.h"
17 // Test instance of WebUI that tracks the data passed to
18 // CallJavascriptFunction().
19 class TestWebUI
: public WebUI
{
22 ~TestWebUI() override
;
24 void ClearTrackedCalls();
27 WebContents
* GetWebContents() const override
;
28 WebUIController
* GetController() const override
;
29 void SetController(WebUIController
* controller
) override
{}
30 float GetDeviceScaleFactor() const override
;
31 const base::string16
& GetOverriddenTitle() const override
;
32 void OverrideTitle(const base::string16
& title
) override
{}
33 ui::PageTransition
GetLinkTransitionType() const override
;
34 void SetLinkTransitionType(ui::PageTransition type
) override
{}
35 int GetBindings() const override
;
36 void SetBindings(int bindings
) override
{}
37 void OverrideJavaScriptFrame(const std::string
& frame_name
) override
{}
38 void AddMessageHandler(WebUIMessageHandler
* handler
) override
{}
39 void RegisterMessageCallback(const std::string
& message
,
40 const MessageCallback
& callback
) override
{}
41 void ProcessWebUIMessage(const GURL
& source_url
,
42 const std::string
& message
,
43 const base::ListValue
& args
) override
{}
44 void CallJavascriptFunction(const std::string
& function_name
) override
;
45 void CallJavascriptFunction(const std::string
& function_name
,
46 const base::Value
& arg1
) override
;
47 void CallJavascriptFunction(const std::string
& function_name
,
48 const base::Value
& arg1
,
49 const base::Value
& arg2
) override
;
50 void CallJavascriptFunction(const std::string
& function_name
,
51 const base::Value
& arg1
,
52 const base::Value
& arg2
,
53 const base::Value
& arg3
) override
;
54 void CallJavascriptFunction(const std::string
& function_name
,
55 const base::Value
& arg1
,
56 const base::Value
& arg2
,
57 const base::Value
& arg3
,
58 const base::Value
& arg4
) override
;
59 void CallJavascriptFunction(
60 const std::string
& function_name
,
61 const std::vector
<const base::Value
*>& args
) override
;
65 explicit CallData(const std::string
& function_name
);
68 void TakeAsArg1(base::Value
* arg
);
69 void TakeAsArg2(base::Value
* arg
);
71 const std::string
& function_name() const { return function_name_
; }
72 const base::Value
* arg1() const { return arg1_
.get(); }
73 const base::Value
* arg2() const { return arg2_
.get(); }
76 std::string function_name_
;
77 scoped_ptr
<base::Value
> arg1_
;
78 scoped_ptr
<base::Value
> arg2_
;
81 const ScopedVector
<CallData
>& call_data() const { return call_data_
; }
84 ScopedVector
<CallData
> call_data_
;
85 base::string16 temp_string_
;
88 } // namespace content
90 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_