OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import <WebKit/WebKit.h> |
| 6 |
| 7 #import "ios/web/public/test/fakes/test_web_view_content_view.h" |
| 8 #import "ios/web/test/web_test_with_web_controller.h" |
| 9 #import "ios/web/test/wk_web_view_crash_utils.h" |
| 10 #include "testing/gtest/include/gtest/gtest-spi.h" |
| 11 |
| 12 namespace { |
| 13 |
| 14 // Fixture to test that the WebTest fixture properly fails tests when the render |
| 15 // process crashes. |
| 16 class WebTestFixtureTest : public web::WebTestWithWebController { |
| 17 protected: |
| 18 void SetUp() override { |
| 19 web::WebTestWithWebController::SetUp(); |
| 20 web_view_.reset([web::BuildTerminatedWKWebView() retain]); |
| 21 base::scoped_nsobject<TestWebViewContentView> web_view_content_view( |
| 22 [[TestWebViewContentView alloc] |
| 23 initWithMockWebView:web_view_ |
| 24 scrollView:[web_view_ scrollView]]); |
| 25 [web_controller() injectWebViewContentView:web_view_content_view]; |
| 26 } |
| 27 |
| 28 base::scoped_nsobject<WKWebView> web_view_; |
| 29 }; |
| 30 |
| 31 // Tests that the WebTest fixture triggers a test failure when a render process |
| 32 // crashes during the test. |
| 33 TEST_F(WebTestFixtureTest, FailsOnRenderCrash) { |
| 34 // EXPECT_FATAL_FAILURE() uses a local class, which cannot access non-static |
| 35 // variables of the enclosing function. |
| 36 static WKWebView* web_view = web_view_; |
| 37 |
| 38 EXPECT_FATAL_FAILURE(web::SimulateWKWebViewCrash(web_view), |
| 39 "Renderer process died unexpectedly"); |
| 40 }; |
| 41 |
| 42 // Tests that |SetIgnoreRenderProcessCrashesDuringTesting()| properly ignores |
| 43 // intentional render process crashes. |
| 44 TEST_F(WebTestFixtureTest, SucceedsOnRenderCrash) { |
| 45 SetIgnoreRenderProcessCrashesDuringTesting(true); |
| 46 web::SimulateWKWebViewCrash(web_view_); |
| 47 }; |
| 48 |
| 49 } // namespace |
OLD | NEW |