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

Unified Diff: ios/web/public/test/web_test.mm

Issue 2666953003: [ios] Automatically fail any WebTest whose render process crashes. (Closed)
Patch Set: Add test. 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/public/test/web_test.mm
diff --git a/ios/web/public/test/web_test.mm b/ios/web/public/test/web_test.mm
index 773261d23a72cf2920de78274dcfe66c2521e112..2f0ac976fe13d497721c3d7adb5ba9354a97b836 100644
--- a/ios/web/public/test/web_test.mm
+++ b/ios/web/public/test/web_test.mm
@@ -6,11 +6,29 @@
#include "base/memory/ptr_util.h"
#include "ios/web/public/active_state_manager.h"
+#include "ios/web/public/web_state/global_web_state_observer.h"
#import "ios/web/public/test/fakes/test_web_client.h"
+namespace {
Eugene But (OOO till 7-30) 2017/02/01 16:43:04 Drop this?
rohitrao (ping after 24h) 2017/02/01 18:22:59 Done.
+
+} // namespace
+
namespace web {
-WebTest::WebTest() : web_client_(base::WrapUnique(new TestWebClient)) {}
+class RendererCrashObserver : public GlobalWebStateObserver {
+ public:
+ RendererCrashObserver() = default;
+ ~RendererCrashObserver() override = default;
+
+ void RenderProcessGone(WebState* web_state) override {
Eugene But (OOO till 7-30) 2017/02/01 16:43:04 Optional nit: Drop |web_state| argument
rohitrao (ping after 24h) 2017/02/01 18:22:59 GlobalWebStateObserver needs to pass this, so that
Eugene But (OOO till 7-30) 2017/02/01 18:41:45 Sorry, what I meant was: |void RenderProcessGone(W
+ FAIL() << "Renderer process died unexpectedly during the test";
+ }
+};
+
+WebTest::WebTest()
+ : web_client_(base::WrapUnique(new TestWebClient)) {
Eugene But (OOO till 7-30) 2017/02/01 16:43:04 Do we need web client? WebTestSuite already sets i
rohitrao (ping after 24h) 2017/02/01 18:22:59 Some tests call GetWebClient(), so leaving this in
+ renderer_crash_observer_ = base::MakeUnique<RendererCrashObserver>();
+}
WebTest::~WebTest() {}
@@ -32,4 +50,12 @@ BrowserState* WebTest::GetBrowserState() {
return &browser_state_;
}
+void WebTest::AllowRenderProcessCrashesDuringTesting(bool allow) {
+ if (allow) {
Eugene But (OOO till 7-30) 2017/02/01 16:43:04 Optional nit: Do you want to use ternary? renderer
rohitrao (ping after 24h) 2017/02/01 18:22:59 If you don't feel strongly, I'll keep this as-is.
+ renderer_crash_observer_ = nullptr;
+ } else {
+ renderer_crash_observer_ = base::MakeUnique<RendererCrashObserver>();
+ }
+}
+
} // namespace web

Powered by Google App Engine
This is Rietveld 408576698