OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
6 #define IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 6 #define IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
7 | 7 |
8 #include "base/ios/block_types.h" | 8 #include "base/ios/block_types.h" |
9 #import "base/ios/weak_nsobject.h" | 9 #import "base/ios/weak_nsobject.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 ~WebTestWithWebState() override; | 23 ~WebTestWithWebState() override; |
24 | 24 |
25 // WebTest overrides. | 25 // WebTest overrides. |
26 void SetUp() override; | 26 void SetUp() override; |
27 void TearDown() override; | 27 void TearDown() override; |
28 | 28 |
29 // base::MessageLoop::TaskObserver overrides. | 29 // base::MessageLoop::TaskObserver overrides. |
30 void WillProcessTask(const base::PendingTask& pending_task) override; | 30 void WillProcessTask(const base::PendingTask& pending_task) override; |
31 void DidProcessTask(const base::PendingTask& pending_task) override; | 31 void DidProcessTask(const base::PendingTask& pending_task) override; |
32 | 32 |
33 // Loads the specified HTML content into the WebController via public APIs. | 33 // Loads the specified HTML content with URL into the WebState. |
| 34 void LoadHtml(NSString* html, const GURL& url); |
| 35 // Loads the specified HTML content into the WebState, using test url name. |
34 void LoadHtml(NSString* html); | 36 void LoadHtml(NSString* html); |
35 // Loads the specified HTML content into the WebController via public APIs. | 37 // Loads the specified HTML content into the WebState, using test url name. |
36 void LoadHtml(const std::string& html); | 38 void LoadHtml(const std::string& html); |
37 // Loads |url| into the WebController via public APIs. | |
38 // Note if anyone uses this to load web pages from the live internet, the | |
39 // tests can be flaky / dependent on content and behavior beyond our control. | |
40 // Use this only when it's impossible to test with static HTML using LoadHtml. | |
41 void LoadURL(const GURL& url); | |
42 // Blocks until both known NSRunLoop-based and known message-loop-based | 39 // Blocks until both known NSRunLoop-based and known message-loop-based |
43 // background tasks have completed | 40 // background tasks have completed |
44 void WaitForBackgroundTasks(); | 41 void WaitForBackgroundTasks(); |
45 // Blocks until known NSRunLoop-based have completed, known message-loop-based | 42 // Blocks until known NSRunLoop-based have completed, known message-loop-based |
46 // background tasks have completed and |condition| evaluates to true. | 43 // background tasks have completed and |condition| evaluates to true. |
47 void WaitForCondition(ConditionBlock condition); | 44 void WaitForCondition(ConditionBlock condition); |
48 // Synchronously executes JavaScript and returns result as id. | 45 // Synchronously executes JavaScript and returns result as id. |
49 id ExecuteJavaScript(NSString* script); | 46 id ExecuteJavaScript(NSString* script); |
50 | 47 |
51 // Returns the base URL of the loaded page. | 48 // Returns the base URL of the loaded page. |
(...skipping 15 matching lines...) Expand all Loading... |
67 // Creates a unique HTML element to look for in | 64 // Creates a unique HTML element to look for in |
68 // ResetPageIfNavigationStalled(). | 65 // ResetPageIfNavigationStalled(). |
69 NSString* CreateLoadCheck(); | 66 NSString* CreateLoadCheck(); |
70 // The web state for testing. | 67 // The web state for testing. |
71 std::unique_ptr<WebState> web_state_; | 68 std::unique_ptr<WebState> web_state_; |
72 }; | 69 }; |
73 | 70 |
74 } // namespace web | 71 } // namespace web |
75 | 72 |
76 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 73 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
OLD | NEW |