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

Side by Side Diff: ios/web/public/test/web_test.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
« no previous file with comments | « ios/web/public/test/web_test.h ('k') | ios/web/public/web_state/global_web_state_observer.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "ios/web/public/test/web_test.h" 5 #include "ios/web/public/test/web_test.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "ios/web/public/active_state_manager.h" 8 #include "ios/web/public/active_state_manager.h"
9 #include "ios/web/public/web_state/global_web_state_observer.h"
9 #import "ios/web/public/test/fakes/test_web_client.h" 10 #import "ios/web/public/test/fakes/test_web_client.h"
10 11
11 namespace web { 12 namespace web {
12 13
13 WebTest::WebTest() : web_client_(base::WrapUnique(new TestWebClient)) {} 14 class WebTestRenderProcessCrashObserver : public GlobalWebStateObserver {
15 public:
16 WebTestRenderProcessCrashObserver() = default;
17 ~WebTestRenderProcessCrashObserver() override = default;
18
19 void RenderProcessGone(WebState* web_state) override {
20 FAIL() << "Renderer process died unexpectedly during the test";
21 }
22 };
23
24 WebTest::WebTest()
25 : web_client_(base::WrapUnique(new TestWebClient)),
26 crash_observer_(base::MakeUnique<WebTestRenderProcessCrashObserver>()) {}
14 27
15 WebTest::~WebTest() {} 28 WebTest::~WebTest() {}
16 29
17 void WebTest::SetUp() { 30 void WebTest::SetUp() {
18 PlatformTest::SetUp(); 31 PlatformTest::SetUp();
19 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(true); 32 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(true);
20 } 33 }
21 34
22 void WebTest::TearDown() { 35 void WebTest::TearDown() {
23 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(false); 36 BrowserState::GetActiveStateManager(&browser_state_)->SetActive(false);
24 PlatformTest::TearDown(); 37 PlatformTest::TearDown();
25 } 38 }
26 39
27 TestWebClient* WebTest::GetWebClient() { 40 TestWebClient* WebTest::GetWebClient() {
28 return static_cast<TestWebClient*>(web_client_.Get()); 41 return static_cast<TestWebClient*>(web_client_.Get());
29 } 42 }
30 43
31 BrowserState* WebTest::GetBrowserState() { 44 BrowserState* WebTest::GetBrowserState() {
32 return &browser_state_; 45 return &browser_state_;
33 } 46 }
34 47
48 void WebTest::SetIgnoreRenderProcessCrashesDuringTesting(bool allow) {
49 if (allow) {
50 crash_observer_ = nullptr;
51 } else {
52 crash_observer_ = base::MakeUnique<WebTestRenderProcessCrashObserver>();
53 }
54 }
55
35 } // namespace web 56 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/public/test/web_test.h ('k') | ios/web/public/web_state/global_web_state_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698