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 with URL into the WebState. | 33 // Loads the specified HTML content into the WebController via public APIs. |
34 void LoadHtml(NSString* html, const GURL& url); | |
35 // Loads the specified HTML content into the WebState, using test url name. | |
36 void LoadHtml(NSString* html); | 34 void LoadHtml(NSString* html); |
37 // Loads the specified HTML content into the WebState, using test url name. | 35 // Loads the specified HTML content into the WebController via public APIs. |
38 void LoadHtml(const std::string& html); | 36 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); |
39 // Blocks until both known NSRunLoop-based and known message-loop-based | 42 // Blocks until both known NSRunLoop-based and known message-loop-based |
40 // background tasks have completed | 43 // background tasks have completed |
41 void WaitForBackgroundTasks(); | 44 void WaitForBackgroundTasks(); |
42 // Blocks until known NSRunLoop-based have completed, known message-loop-based | 45 // Blocks until known NSRunLoop-based have completed, known message-loop-based |
43 // background tasks have completed and |condition| evaluates to true. | 46 // background tasks have completed and |condition| evaluates to true. |
44 void WaitForCondition(ConditionBlock condition); | 47 void WaitForCondition(ConditionBlock condition); |
45 // Synchronously executes JavaScript and returns result as id. | 48 // Synchronously executes JavaScript and returns result as id. |
46 id ExecuteJavaScript(NSString* script); | 49 id ExecuteJavaScript(NSString* script); |
47 | 50 |
48 // Returns the base URL of the loaded page. | 51 // Returns the base URL of the loaded page. |
(...skipping 15 matching lines...) Expand all Loading... |
64 // Creates a unique HTML element to look for in | 67 // Creates a unique HTML element to look for in |
65 // ResetPageIfNavigationStalled(). | 68 // ResetPageIfNavigationStalled(). |
66 NSString* CreateLoadCheck(); | 69 NSString* CreateLoadCheck(); |
67 // The web state for testing. | 70 // The web state for testing. |
68 std::unique_ptr<WebState> web_state_; | 71 std::unique_ptr<WebState> web_state_; |
69 }; | 72 }; |
70 | 73 |
71 } // namespace web | 74 } // namespace web |
72 | 75 |
73 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 76 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
OLD | NEW |