Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: ios/web/test/web_test_unittest.mm

Issue 2666953003: [ios] Automatically fail any WebTest whose render process crashes. (Closed)
Patch Set: Fix comment. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 an inner class, which cannot access member
35 // variables or local variables. Work around this by using a local static
36 // variable to hold the WKWebView pointer.
37 static WKWebView* web_view = web_view_;
Eugene But (OOO till 7-30) 2017/02/01 18:41:45 How about this comment?: // EXPECT_FATAL_FAILURE()
rohitrao (ping after 24h) 2017/02/01 20:29:13 Done.
38
39 EXPECT_FATAL_FAILURE(web::SimulateWKWebViewCrash(web_view),
40 "Renderer process died unexpectedly");
41 };
42
43 // Tests that |SetIgnoreRenderProcessCrashesDuringTesting()| properly ignores
44 // intentional render process crashes.
45 TEST_F(WebTestFixtureTest, SucceedsOnRenderCrash) {
46 SetIgnoreRenderProcessCrashesDuringTesting(true);
47 web::SimulateWKWebViewCrash(web_view_);
48 };
49
50 } // namespace
OLDNEW
« no previous file with comments | « ios/web/public/web_state/global_web_state_observer.h ('k') | ios/web/web_state/global_web_state_event_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698