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 <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.
| |
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 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
| |
15 | |
16 void SimulateRenderProcessCrash() { | |
17 web::SimulateWKWebViewCrash(g_web_view); | |
18 } | |
19 | |
20 // Fixture to test that the WebTest fixture properly fails tests when the render | |
21 // process crashes. | |
22 class WebTestFixtureTest : public web::WebTestWithWebController { | |
23 protected: | |
24 void SetUp() override { | |
25 web::WebTestWithWebController::SetUp(); | |
26 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.
| |
27 g_web_view = webView_; | |
28 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.
| |
29 [[TestWebViewContentView alloc] | |
30 initWithMockWebView:webView_ | |
31 scrollView:[webView_ scrollView]]); | |
32 [web_controller() injectWebViewContentView:webViewContentView]; | |
33 } | |
34 | |
35 void TearDown() override { | |
36 g_web_view = nil; | |
37 web::WebTestWithWebController::TearDown(); | |
38 } | |
39 | |
40 base::scoped_nsobject<WKWebView> webView_; | |
41 }; | |
42 | |
43 // Tests that WebStateDelegate::RenderProcessGone is called when WKWebView web | |
44 // process has crashed. | |
45 TEST_F(WebTestFixtureTest, FailsOnRenderCrash) { | |
46 EXPECT_FATAL_FAILURE(SimulateRenderProcessCrash(), | |
47 "Renderer process died unexpectedly"); | |
48 }; | |
49 | |
50 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.
| |
51 AllowRenderProcessCrashesDuringTesting(true); | |
52 SimulateRenderProcessCrash(); | |
53 }; | |
54 | |
55 } // namespace | |
OLD | NEW |