1 // Copyright 2014 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 IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_
6 #define IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_
10 #include "base/strings/string16.h"
11 #include "ios/web/public/web_state/url_verification_constants.h"
12 #include "ios/web/public/web_state/web_state.h"
17 // Minimal implementation of WebState, to be used in tests.
18 class TestWebState
: public WebState
{
21 ~TestWebState() override
;
23 // WebState implementation.
24 UIView
* GetView() override
;
25 WebViewType
GetWebViewType() const override
;
26 BrowserState
* GetBrowserState() const override
;
27 void OpenURL(const OpenURLParams
& params
) override
{}
28 NavigationManager
* GetNavigationManager() override
;
29 CRWJSInjectionReceiver
* GetJSInjectionReceiver() const override
;
30 const std::string
& GetContentsMimeType() const override
;
31 const std::string
& GetContentLanguageHeader() const override
;
32 bool ContentIsHTML() const override
;
33 const base::string16
& GetTitle() const override
;
34 bool IsLoading() const override
;
35 const GURL
& GetVisibleURL() const override
;
36 const GURL
& GetLastCommittedURL() const override
;
37 GURL
GetCurrentURL(URLVerificationTrustLevel
* trust_level
) const override
;
38 void ShowTransientContentView(CRWContentView
* content_view
) override
{}
39 void AddScriptCommandCallback(const ScriptCommandCallback
& callback
,
40 const std::string
& command_prefix
) override
{}
41 void RemoveScriptCommandCallback(const std::string
& command_prefix
) override
{
43 CRWWebViewProxyType
GetWebViewProxy() const override
;
44 bool IsShowingWebInterstitial() const override
;
45 WebInterstitial
* GetWebInterstitial() const override
;
46 void AddObserver(WebStateObserver
* observer
) override
{}
47 void RemoveObserver(WebStateObserver
* observer
) override
{}
48 void AddPolicyDecider(WebStatePolicyDecider
* decider
) override
{}
49 void RemovePolicyDecider(WebStatePolicyDecider
* decider
) override
{}
50 int DownloadImage(const GURL
& url
,
52 uint32_t max_bitmap_size
,
54 const ImageDownloadCallback
& callback
) override
;
56 // Setters for test data.
57 void SetContentIsHTML(bool content_is_html
);
58 void SetCurrentURL(const GURL
& url
);
59 void SetTrustLevel(URLVerificationTrustLevel trust_level
);
63 base::string16 title_
;
64 URLVerificationTrustLevel trust_level_
;
65 bool content_is_html_
;
66 std::string mime_type_
;
67 std::string content_language_
;
72 #endif // IOS_WEB_PUBLIC_TEST_TEST_WEB_STATE_H_