| 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" |
| 11 #include "ui/base/page_transition_types.h" | |
| 12 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 13 | 12 |
| 14 namespace web { | 13 namespace web { |
| 15 | 14 |
| 16 class WebState; | 15 class WebState; |
| 17 | 16 |
| 18 // Base test fixture that provides WebState for testing. | 17 // Base test fixture that provides WebState for testing. |
| 19 class WebTestWithWebState : public WebTest, | 18 class WebTestWithWebState : public WebTest, |
| 20 public base::MessageLoop::TaskObserver { | 19 public base::MessageLoop::TaskObserver { |
| 21 protected: | 20 protected: |
| 22 WebTestWithWebState(); | 21 WebTestWithWebState(); |
| 23 ~WebTestWithWebState() override; | 22 ~WebTestWithWebState() override; |
| 24 | 23 |
| 25 // WebTest overrides. | 24 // WebTest overrides. |
| 26 void SetUp() override; | 25 void SetUp() override; |
| 27 void TearDown() override; | 26 void TearDown() override; |
| 28 | 27 |
| 29 // Adds a pending item to the NavigationManager associated with the WebState. | |
| 30 void AddPendingItem(const GURL& url, ui::PageTransition transition); | |
| 31 | |
| 32 // Loads the specified HTML content with URL into the WebState. | 28 // Loads the specified HTML content with URL into the WebState. |
| 33 void LoadHtml(NSString* html, const GURL& url); | 29 void LoadHtml(NSString* html, const GURL& url); |
| 34 // Loads the specified HTML content into the WebState, using test url name. | 30 // Loads the specified HTML content into the WebState, using test url name. |
| 35 void LoadHtml(NSString* html); | 31 void LoadHtml(NSString* html); |
| 36 // 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. |
| 37 void LoadHtml(const std::string& html); | 33 void LoadHtml(const std::string& html); |
| 38 // Blocks until both known NSRunLoop-based and known message-loop-based | 34 // Blocks until both known NSRunLoop-based and known message-loop-based |
| 39 // background tasks have completed | 35 // background tasks have completed |
| 40 void WaitForBackgroundTasks(); | 36 void WaitForBackgroundTasks(); |
| 41 // Blocks until known NSRunLoop-based have completed, known message-loop-based | 37 // Blocks until known NSRunLoop-based have completed, known message-loop-based |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 | 56 |
| 61 // The web state for testing. | 57 // The web state for testing. |
| 62 std::unique_ptr<WebState> web_state_; | 58 std::unique_ptr<WebState> web_state_; |
| 63 // true if a task has been processed. | 59 // true if a task has been processed. |
| 64 bool processed_a_task_; | 60 bool processed_a_task_; |
| 65 }; | 61 }; |
| 66 | 62 |
| 67 } // namespace web | 63 } // namespace web |
| 68 | 64 |
| 69 #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 |