| 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_H_ | 5 #ifndef IOS_WEB_PUBLIC_TEST_WEB_TEST_H_ |
| 6 #define IOS_WEB_PUBLIC_TEST_WEB_TEST_H_ | 6 #define IOS_WEB_PUBLIC_TEST_WEB_TEST_H_ |
| 7 | 7 |
| 8 #include "ios/web/public/test/fakes/test_browser_state.h" | 8 #include "ios/web/public/test/fakes/test_browser_state.h" |
| 9 #include "ios/web/public/test/scoped_testing_web_client.h" | 9 #include "ios/web/public/test/scoped_testing_web_client.h" |
| 10 #include "ios/web/public/test/test_web_thread_bundle.h" | 10 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 12 | 12 |
| 13 namespace web { | 13 namespace web { |
| 14 | 14 |
| 15 class BrowserState; | 15 class BrowserState; |
| 16 class TestWebClient; | 16 class TestWebClient; |
| 17 class WebTestRenderProcessCrashObserver; |
| 17 | 18 |
| 18 // A test fixture for web tests that need a minimum environment set up that | 19 // A test fixture for web tests that need a minimum environment set up that |
| 19 // mimics a web embedder. | 20 // mimics a web embedder. |
| 20 class WebTest : public PlatformTest { | 21 class WebTest : public PlatformTest { |
| 21 protected: | 22 protected: |
| 22 WebTest(); | 23 WebTest(); |
| 23 ~WebTest() override; | 24 ~WebTest() override; |
| 24 | 25 |
| 25 // PlatformTest methods. | 26 // PlatformTest methods. |
| 26 void SetUp() override; | 27 void SetUp() override; |
| 27 void TearDown() override; | 28 void TearDown() override; |
| 28 | 29 |
| 29 // Returns the WebClient that is used for testing. | 30 // Returns the WebClient that is used for testing. |
| 30 TestWebClient* GetWebClient(); | 31 TestWebClient* GetWebClient(); |
| 31 | 32 |
| 32 // Returns the BrowserState that is used for testing. | 33 // Returns the BrowserState that is used for testing. |
| 33 virtual BrowserState* GetBrowserState(); | 34 virtual BrowserState* GetBrowserState(); |
| 34 | 35 |
| 36 // If called with |true|, prevents the test fixture from automatically failing |
| 37 // when a render process crashes during the test. This is useful for tests |
| 38 // that intentionally crash the render process. By default, the WebTest |
| 39 // fixture will fail if a render process crashes. |
| 40 void SetIgnoreRenderProcessCrashesDuringTesting(bool allow); |
| 41 |
| 35 private: | 42 private: |
| 36 // The WebClient used in tests. | 43 // The WebClient used in tests. |
| 37 ScopedTestingWebClient web_client_; | 44 ScopedTestingWebClient web_client_; |
| 38 // The threads used for testing. | 45 // The threads used for testing. |
| 39 web::TestWebThreadBundle thread_bundle_; | 46 web::TestWebThreadBundle thread_bundle_; |
| 40 // The browser state used in tests. | 47 // The browser state used in tests. |
| 41 TestBrowserState browser_state_; | 48 TestBrowserState browser_state_; |
| 49 |
| 50 // Triggers test failures if a render process dies during the test. |
| 51 std::unique_ptr<WebTestRenderProcessCrashObserver> crash_observer_; |
| 42 }; | 52 }; |
| 43 | 53 |
| 44 } // namespace web | 54 } // namespace web |
| 45 | 55 |
| 46 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_H_ | 56 #endif // IOS_WEB_PUBLIC_TEST_WEB_TEST_H_ |
| OLD | NEW |