summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordroger <droger@chromium.org>2014-12-10 01:39:04 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-10 09:39:25 +0000
commit2f863352c65cba331b1105a1e4e74efc5ecbcbb0 (patch)
tree18189a36bb7c79aa1e627a3844571cc47082721d
parentc6296b23dfb11269a1375ee84617cb7a700b7e25 (diff)
downloadchromium_src-2f863352c65cba331b1105a1e4e74efc5ecbcbb0.zip
chromium_src-2f863352c65cba331b1105a1e4e74efc5ecbcbb0.tar.gz
chromium_src-2f863352c65cba331b1105a1e4e74efc5ecbcbb0.tar.bz2
Upstream iOS TestWebState
Review URL: https://codereview.chromium.org/787863002 Cr-Commit-Position: refs/heads/master@{#307664}
-rw-r--r--ios/web/ios_web.gyp2
-rw-r--r--ios/web/public/test/test_web_state.cc41
-rw-r--r--ios/web/public/test/test_web_state.h44
3 files changed, 87 insertions, 0 deletions
diff --git a/ios/web/ios_web.gyp b/ios/web/ios_web.gyp
index 0b7f927..f22e2ba 100644
--- a/ios/web/ios_web.gyp
+++ b/ios/web/ios_web.gyp
@@ -56,6 +56,8 @@
'sources': [
'public/test/test_browser_state.cc',
'public/test/test_browser_state.h',
+ 'public/test/test_web_state.cc',
+ 'public/test/test_web_state.h',
],
},
],
diff --git a/ios/web/public/test/test_web_state.cc b/ios/web/public/test/test_web_state.cc
new file mode 100644
index 0000000..220b648
--- /dev/null
+++ b/ios/web/public/test/test_web_state.cc
@@ -0,0 +1,41 @@
+// Copyright 2014 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 "ios/web/public/test/test_web_state.h"
+
+namespace web {
+
+BrowserState* TestWebState::GetBrowserState() const {
+ return nullptr;
+}
+
+NavigationManager* TestWebState::GetNavigationManager() {
+ return nullptr;
+}
+
+CRWJSInjectionReceiver* TestWebState::GetJSInjectionReceiver() const {
+ return nullptr;
+}
+
+const std::string& TestWebState::GetContentsMimeType() const {
+ return mime_type_;
+}
+
+const std::string& TestWebState::GetContentLanguageHeader() const {
+ return content_language_;
+}
+
+bool TestWebState::ContentIsHTML() const {
+ return true;
+}
+
+const GURL& TestWebState::GetVisibleURL() const {
+ return url_;
+}
+
+const GURL& TestWebState::GetLastCommittedURL() const {
+ return url_;
+}
+
+} // namespace web
diff --git a/ios/web/public/test/test_web_state.h b/ios/web/public/test/test_web_state.h
new file mode 100644
index 0000000..7a7f4d5
--- /dev/null
+++ b/ios/web/public/test/test_web_state.h
@@ -0,0 +1,44 @@
+// Copyright 2014 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 IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_
+#define IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_
+
+#include <string>
+
+#include "ios/web/public/web_state/web_state.h"
+#include "url/gurl.h"
+
+namespace web {
+
+// Minimal implementation of WebState, to be used in tests.
+class TestWebState : public WebState {
+ public:
+ // WebState implementation.
+ virtual BrowserState* GetBrowserState() const override;
+ virtual void OpenURL(const OpenURLParams& params) override {}
+ virtual NavigationManager* GetNavigationManager() override;
+ virtual CRWJSInjectionReceiver* GetJSInjectionReceiver() const override;
+ virtual const std::string& GetContentsMimeType() const override;
+ virtual const std::string& GetContentLanguageHeader() const override;
+ virtual bool ContentIsHTML() const override;
+ virtual const GURL& GetVisibleURL() const override;
+ virtual const GURL& GetLastCommittedURL() const override;
+ virtual void AddScriptCommandCallback(
+ const ScriptCommandCallback& callback,
+ const std::string& command_prefix) override {}
+ virtual void RemoveScriptCommandCallback(
+ const std::string& command_prefix) override {}
+ virtual void AddObserver(WebStateObserver* observer) override {}
+ virtual void RemoveObserver(WebStateObserver* observer) override {}
+
+ private:
+ GURL url_;
+ std::string mime_type_;
+ std::string content_language_;
+};
+
+} // namespace web
+
+#endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_