Skip to content

Commit

Permalink
Upstream iOS TestWebState
Browse files Browse the repository at this point in the history
Review URL: https://codereview.chromium.org/787863002

Cr-Commit-Position: refs/heads/master@{#307664}
  • Loading branch information
droger authored and Commit bot committed Dec 10, 2014
1 parent c6296b2 commit 2f86335
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ios/web/ios_web.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
],
Expand Down
41 changes: 41 additions & 0 deletions ios/web/public/test/test_web_state.cc
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions ios/web/public/test/test_web_state.h
Original file line number Diff line number Diff line change
@@ -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_

0 comments on commit 2f86335

Please sign in to comment.