[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / content / public / test / test_web_ui.h
blob38321ebb5bc031e0208d46935ec180442fb8521f
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_
8 #include <vector>
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"
15 namespace content {
17 // Test instance of WebUI that tracks the data passed to
18 // CallJavascriptFunction().
19 class TestWebUI : public WebUI {
20 public:
21 TestWebUI();
22 ~TestWebUI() override;
24 void ClearTrackedCalls();
25 void set_web_contents(WebContents* web_contents) {
26 web_contents_ = web_contents;
29 // WebUI overrides.
30 WebContents* GetWebContents() const override;
31 WebUIController* GetController() const override;
32 void SetController(WebUIController* controller) override {}
33 float GetDeviceScaleFactor() const override;
34 const base::string16& GetOverriddenTitle() const override;
35 void OverrideTitle(const base::string16& title) override {}
36 ui::PageTransition GetLinkTransitionType() const override;
37 void SetLinkTransitionType(ui::PageTransition type) override {}
38 int GetBindings() const override;
39 void SetBindings(int bindings) override {}
40 void OverrideJavaScriptFrame(const std::string& frame_name) override {}
41 void AddMessageHandler(WebUIMessageHandler* handler) override;
42 void RegisterMessageCallback(const std::string& message,
43 const MessageCallback& callback) override {}
44 void ProcessWebUIMessage(const GURL& source_url,
45 const std::string& message,
46 const base::ListValue& args) override {}
47 void CallJavascriptFunction(const std::string& function_name) override;
48 void CallJavascriptFunction(const std::string& function_name,
49 const base::Value& arg1) override;
50 void CallJavascriptFunction(const std::string& function_name,
51 const base::Value& arg1,
52 const base::Value& arg2) override;
53 void CallJavascriptFunction(const std::string& function_name,
54 const base::Value& arg1,
55 const base::Value& arg2,
56 const base::Value& arg3) override;
57 void CallJavascriptFunction(const std::string& function_name,
58 const base::Value& arg1,
59 const base::Value& arg2,
60 const base::Value& arg3,
61 const base::Value& arg4) override;
62 void CallJavascriptFunction(
63 const std::string& function_name,
64 const std::vector<const base::Value*>& args) override;
66 class CallData {
67 public:
68 explicit CallData(const std::string& function_name);
69 ~CallData();
71 void TakeAsArg1(base::Value* arg);
72 void TakeAsArg2(base::Value* arg);
74 const std::string& function_name() const { return function_name_; }
75 const base::Value* arg1() const { return arg1_.get(); }
76 const base::Value* arg2() const { return arg2_.get(); }
78 private:
79 std::string function_name_;
80 scoped_ptr<base::Value> arg1_;
81 scoped_ptr<base::Value> arg2_;
84 const ScopedVector<CallData>& call_data() const { return call_data_; }
86 private:
87 ScopedVector<CallData> call_data_;
88 ScopedVector<WebUIMessageHandler> handlers_;
89 base::string16 temp_string_;
90 WebContents* web_contents_;
93 } // namespace content
95 #endif // CONTENT_PUBLIC_TEST_TEST_WEB_UI_H_