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..5960716b1a5b1a2459938b509bb33036be6e4acc |
--- /dev/null |
+++ b/ios/web/test/web_test_unittest.mm |
@@ -0,0 +1,55 @@ |
+// 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 <UIKit/UIKit.h> |
Eugene But (OOO till 7-30)
2017/02/01 16:43:04
nit: s/<UIKit/UIKit.h>/<WKWebKit/WKWebKit.h> ?
Loo
rohitrao (ping after 24h)
2017/02/01 18:23:00
Done.
|
+ |
+#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 { |
+ |
+WKWebView* g_web_view = nil; |
Eugene But (OOO till 7-30)
2017/02/01 16:43:04
Should |g_web_view| be a member of WebTestFixtureT
rohitrao (ping after 24h)
2017/02/01 18:23:00
I'm still fighting with gtest on this. EXPECT_FAT
Eugene But (OOO till 7-30)
2017/02/01 18:41:45
Oh that's because they use local class, which can
|
+ |
+void SimulateRenderProcessCrash() { |
+ web::SimulateWKWebViewCrash(g_web_view); |
+} |
+ |
+// 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(); |
+ webView_.reset([web::BuildTerminatedWKWebView() retain]); |
Eugene But (OOO till 7-30)
2017/02/01 16:43:04
s/webView_/web_view_
rohitrao (ping after 24h)
2017/02/01 18:23:00
Done.
|
+ g_web_view = webView_; |
+ base::scoped_nsobject<TestWebViewContentView> webViewContentView( |
Eugene But (OOO till 7-30)
2017/02/01 16:43:04
s/webViewContentView/web_view_content_view
rohitrao (ping after 24h)
2017/02/01 18:23:00
Done.
|
+ [[TestWebViewContentView alloc] |
+ initWithMockWebView:webView_ |
+ scrollView:[webView_ scrollView]]); |
+ [web_controller() injectWebViewContentView:webViewContentView]; |
+ } |
+ |
+ void TearDown() override { |
+ g_web_view = nil; |
+ web::WebTestWithWebController::TearDown(); |
+ } |
+ |
+ base::scoped_nsobject<WKWebView> webView_; |
+}; |
+ |
+// Tests that WebStateDelegate::RenderProcessGone is called when WKWebView web |
+// process has crashed. |
+TEST_F(WebTestFixtureTest, FailsOnRenderCrash) { |
+ EXPECT_FATAL_FAILURE(SimulateRenderProcessCrash(), |
+ "Renderer process died unexpectedly"); |
+}; |
+ |
+TEST_F(WebTestFixtureTest, SucceedsOnRenderCrash) { |
Eugene But (OOO till 7-30)
2017/02/01 16:43:04
Please add comments
rohitrao (ping after 24h)
2017/02/01 18:23:00
Done.
|
+ AllowRenderProcessCrashesDuringTesting(true); |
+ SimulateRenderProcessCrash(); |
+}; |
+ |
+} // namespace |