| 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 #import "base/ios/block_types.h" | 8 #import "base/ios/block_types.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "ios/web/public/test/web_test.h" | 10 #include "ios/web/public/test/web_test.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 // Loads the specified HTML content into the WebState, using test url name. | 32 // Loads the specified HTML content into the WebState, using test url name. |
| 33 void LoadHtml(const std::string& html); | 33 void LoadHtml(const std::string& html); |
| 34 // Blocks until both known NSRunLoop-based and known message-loop-based | 34 // Blocks until both known NSRunLoop-based and known message-loop-based |
| 35 // background tasks have completed | 35 // background tasks have completed |
| 36 void WaitForBackgroundTasks(); | 36 void WaitForBackgroundTasks(); |
| 37 // Blocks until known NSRunLoop-based have completed, known message-loop-based | 37 // Blocks until known NSRunLoop-based have completed, known message-loop-based |
| 38 // background tasks have completed and |condition| evaluates to true. | 38 // background tasks have completed and |condition| evaluates to true. |
| 39 void WaitForCondition(ConditionBlock condition); | 39 void WaitForCondition(ConditionBlock condition); |
| 40 // Synchronously executes JavaScript and returns result as id. | 40 // Synchronously executes JavaScript and returns result as id. |
| 41 id ExecuteJavaScript(NSString* script); | 41 id ExecuteJavaScript(NSString* script); |
| 42 // Destroys underlying WebState. web_state() will return null after this call. |
| 43 void DestroyWebState(); |
| 42 | 44 |
| 43 // Returns the base URL of the loaded page. | 45 // Returns the base URL of the loaded page. |
| 44 std::string BaseUrl() const; | 46 std::string BaseUrl() const; |
| 45 | 47 |
| 46 // Returns web state for this web controller. | 48 // Returns web state for this web controller. |
| 47 web::WebState* web_state(); | 49 web::WebState* web_state(); |
| 48 const web::WebState* web_state() const; | 50 const web::WebState* web_state() const; |
| 49 | 51 |
| 50 private: | 52 private: |
| 51 // base::MessageLoop::TaskObserver overrides. | 53 // base::MessageLoop::TaskObserver overrides. |
| 52 void WillProcessTask(const base::PendingTask& pending_task) override; | 54 void WillProcessTask(const base::PendingTask& pending_task) override; |
| 53 void DidProcessTask(const base::PendingTask& pending_task) override; | 55 void DidProcessTask(const base::PendingTask& pending_task) override; |
| 54 | 56 |
| 55 // The web state for testing. | 57 // The web state for testing. |
| 56 std::unique_ptr<WebState> web_state_; | 58 std::unique_ptr<WebState> web_state_; |
| 57 // true if a task has been processed. | 59 // true if a task has been processed. |
| 58 bool processed_a_task_; | 60 bool processed_a_task_; |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 } // namespace web | 63 } // namespace web |
| 62 | 64 |
| 63 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ | 65 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_WITH_WEB_STATE_H_ |
| OLD | NEW |