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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2645783002: Replaced webControllerWebProcessDidCrash: with RenderProcessGone. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | ios/web/web_state/web_state_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 webView_.reset([web::BuildTerminatedWKWebView() retain]); 1015 webView_.reset([web::BuildTerminatedWKWebView() retain]);
1016 base::scoped_nsobject<TestWebViewContentView> webViewContentView( 1016 base::scoped_nsobject<TestWebViewContentView> webViewContentView(
1017 [[TestWebViewContentView alloc] 1017 [[TestWebViewContentView alloc]
1018 initWithMockWebView:webView_ 1018 initWithMockWebView:webView_
1019 scrollView:[webView_ scrollView]]); 1019 scrollView:[webView_ scrollView]]);
1020 [web_controller() injectWebViewContentView:webViewContentView]; 1020 [web_controller() injectWebViewContentView:webViewContentView];
1021 } 1021 }
1022 base::scoped_nsobject<WKWebView> webView_; 1022 base::scoped_nsobject<WKWebView> webView_;
1023 }; 1023 };
1024 1024
1025 // Tests that -[CRWWebDelegate webControllerWebProcessDidCrash:] is called 1025 // Tests that WebStateDelegate::RenderProcessGone is called when WKWebView web
1026 // when WKWebView web process has crashed. 1026 // process has crashed.
1027 TEST_F(CRWWebControllerWebProcessTest, Crash) { 1027 TEST_F(CRWWebControllerWebProcessTest, Crash) {
1028 id delegate = [OCMockObject niceMockForProtocol:@protocol(CRWWebDelegate)]; 1028 // Observes and waits for RenderProcessGone call.
1029 [[delegate expect] webControllerWebProcessDidCrash:web_controller()]; 1029 class RenderProcessGoneObserver : public web::WebStateObserver {
1030 public:
1031 explicit RenderProcessGoneObserver(web::WebState* web_state)
1032 : web::WebStateObserver(web_state) {}
1033 void WaitForRenderProcessGone() const {
1034 base::test::ios::WaitUntilCondition(^{
1035 return render_process_gone_;
1036 });
1037 }
1038 // WebStateObserver overrides:
1039 void RenderProcessGone() override { render_process_gone_ = true; }
1030 1040
1031 [web_controller() setDelegate:delegate]; 1041 private:
1042 bool render_process_gone_ = false;
1043 };
1044
1045 RenderProcessGoneObserver observer(web_state());
1032 web::SimulateWKWebViewCrash(webView_); 1046 web::SimulateWKWebViewCrash(webView_);
1047 observer.WaitForRenderProcessGone();
1033 1048
1034 EXPECT_OCMOCK_VERIFY(delegate);
1035 EXPECT_FALSE([web_controller() isViewAlive]); 1049 EXPECT_FALSE([web_controller() isViewAlive]);
1036 [web_controller() setDelegate:nil];
1037 }; 1050 };
1038 1051
1039 } // namespace 1052 } // namespace
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | ios/web/web_state/web_state_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698