OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef IOS_WEB_TEST_WEB_INT_TEST_H_ | 5 #ifndef IOS_WEB_TEST_WEB_INT_TEST_H_ |
6 #define IOS_WEB_TEST_WEB_INT_TEST_H_ | 6 #define IOS_WEB_TEST_WEB_INT_TEST_H_ |
7 | 7 |
8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
9 | 9 |
| 10 #import "base/ios/block_types.h" |
| 11 #import "ios/web/public/navigation_manager.h" |
10 #include "ios/web/public/test/web_test.h" | 12 #include "ios/web/public/test/web_test.h" |
| 13 #import "ios/web/public/web_state/web_state.h" |
| 14 |
| 15 class GURL; |
11 | 16 |
12 namespace web { | 17 namespace web { |
13 | 18 |
| 19 class IntTestWebStateObserver; |
| 20 |
14 // A test fixture for integration tests that need to bring up the HttpServer. | 21 // A test fixture for integration tests that need to bring up the HttpServer. |
15 class WebIntTest : public WebTest { | 22 class WebIntTest : public WebTest { |
16 protected: | 23 protected: |
17 WebIntTest(); | 24 WebIntTest(); |
18 ~WebIntTest() override; | 25 ~WebIntTest() override; |
19 | 26 |
20 // WebTest methods. | 27 // WebTest methods. |
21 void SetUp() override; | 28 void SetUp() override; |
22 void TearDown() override; | 29 void TearDown() override; |
23 | 30 |
| 31 // The WebState and NavigationManager used by this test fixture. |
| 32 WebState* web_state() { return web_state_.get(); } |
| 33 NavigationManager* navigation_manager() { |
| 34 return web_state()->GetNavigationManager(); |
| 35 } |
| 36 |
| 37 // Synchronously executes |script| on |web_state|'s JS injection receiver and |
| 38 // returns the result. |
| 39 id ExecuteJavaScript(NSString* script); |
| 40 |
| 41 // Executes |block| and waits until |url| is successfully loaded in |
| 42 // |web_state_|. |
| 43 void ExecuteBlockAndWaitForLoad(const GURL& url, ProceduralBlock block); |
| 44 |
| 45 // Navigates |web_state_| to |url| and waits for the page to be loaded. |
| 46 void LoadUrl(const GURL& url); |
| 47 |
24 // Synchronously removes data from |data_store|. | 48 // Synchronously removes data from |data_store|. |
25 // |websiteDataTypes| is from the constants defined in | 49 // |websiteDataTypes| is from the constants defined in |
26 // "WebKit/WKWebsiteDataRecord". | 50 // "WebKit/WKWebsiteDataRecord". |
27 void RemoveWKWebViewCreatedData(WKWebsiteDataStore* data_store, | 51 void RemoveWKWebViewCreatedData(WKWebsiteDataStore* data_store, |
28 NSSet* websiteDataTypes); | 52 NSSet* websiteDataTypes); |
29 | 53 |
| 54 // Returns the index of |item| in the |navigation_manager|'s session history, |
| 55 // or NSNotFound if it is not present. |
| 56 NSInteger GetIndexOfNavigationItem(const web::NavigationItem* item); |
| 57 |
| 58 private: |
| 59 // WebState used to load pages. |
| 60 std::unique_ptr<WebState> web_state_; |
| 61 // WebStateObserver used to wait for page loads. |
| 62 std::unique_ptr<IntTestWebStateObserver> observer_; |
30 }; | 63 }; |
31 | 64 |
32 } // namespace web | 65 } // namespace web |
33 | 66 |
34 #endif // IOS_WEB_TEST_WEB_INT_TEST_H_ | 67 #endif // IOS_WEB_TEST_WEB_INT_TEST_H_ |
OLD | NEW |