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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/test/web_test_unittest.mm
diff --git a/ios/web/test/web_test_unittest.mm b/ios/web/test/web_test_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d6dabac86afacbd33ea297b051ed4157b9d0dd32
--- /dev/null
+++ b/ios/web/test/web_test_unittest.mm
@@ -0,0 +1,49 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <WebKit/WebKit.h>
+
+#import "ios/web/public/test/fakes/test_web_view_content_view.h"
+#import "ios/web/test/web_test_with_web_controller.h"
+#import "ios/web/test/wk_web_view_crash_utils.h"
+#include "testing/gtest/include/gtest/gtest-spi.h"
+
+namespace {
+
+// Fixture to test that the WebTest fixture properly fails tests when the render
+// process crashes.
+class WebTestFixtureTest : public web::WebTestWithWebController {
+ protected:
+ void SetUp() override {
+ web::WebTestWithWebController::SetUp();
+ web_view_.reset([web::BuildTerminatedWKWebView() retain]);
+ base::scoped_nsobject<TestWebViewContentView> web_view_content_view(
+ [[TestWebViewContentView alloc]
+ initWithMockWebView:web_view_
+ scrollView:[web_view_ scrollView]]);
+ [web_controller() injectWebViewContentView:web_view_content_view];
+ }
+
+ base::scoped_nsobject<WKWebView> web_view_;
+};
+
+// Tests that the WebTest fixture triggers a test failure when a render process
+// crashes during the test.
+TEST_F(WebTestFixtureTest, FailsOnRenderCrash) {
+ // EXPECT_FATAL_FAILURE() uses a local class, which cannot access non-static
+ // variables of the enclosing function.
+ static WKWebView* web_view = web_view_;
+
+ EXPECT_FATAL_FAILURE(web::SimulateWKWebViewCrash(web_view),
+ "Renderer process died unexpectedly");
+};
+
+// Tests that |SetIgnoreRenderProcessCrashesDuringTesting()| properly ignores
+// intentional render process crashes.
+TEST_F(WebTestFixtureTest, SucceedsOnRenderCrash) {
+ SetIgnoreRenderProcessCrashesDuringTesting(true);
+ web::SimulateWKWebViewCrash(web_view_);
+};
+
+} // namespace
« 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