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