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

Unified Diff: ios/web_view/test/chrome_web_view_test.mm

Issue 2892193002: Add unittest to test CWVWebView. (Closed)
Patch Set: Created 3 years, 7 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_view/test/chrome_web_view_test.mm
diff --git a/ios/web_view/test/chrome_web_view_test.mm b/ios/web_view/test/chrome_web_view_test.mm
new file mode 100644
index 0000000000000000000000000000000000000000..364719cc98cad59f2a8caa094393bd1ac80b6410
--- /dev/null
+++ b/ios/web_view/test/chrome_web_view_test.mm
@@ -0,0 +1,44 @@
+// 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 "ios/web_view/test/chrome_web_view_test.h"
+
+#import <ChromeWebView/ChromeWebView.h>
+#import <Foundation/Foundation.h>
+
+#import "ios/testing/wait_util.h"
+#include "ios/web_view/test/test_server.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+ChromeWebViewTest::ChromeWebViewTest() {}
+
+ChromeWebViewTest::~ChromeWebViewTest() = default;
+
+void ChromeWebViewTest::SetUp() {
+ PlatformTest::SetUp();
+ ios_web_view::TestServer::Start();
Eugene But (OOO till 7-30) 2017/05/19 18:39:49 Can we be more consistent with ios_web_inttets and
michaeldo 2017/05/23 16:20:52 Unfortunately, I don't think so. See my comment in
+}
+
+void ChromeWebViewTest::TearDown() {
+ ios_web_view::TestServer::Shutdown();
+ PlatformTest::TearDown();
+}
+
+void ChromeWebViewTest::LoadURL(CWVWebView* web_view, NSURL* URL) {
+ [web_view loadRequest:[NSURLRequest requestWithURL:URL]];
+
+ WaitForPageLoadCompletion(web_view);
+}
+
+void ChromeWebViewTest::WaitForPageLoadCompletion(CWVWebView* web_view) {
+ BOOL success =
+ testing::WaitUntilConditionOrTimeout(testing::kWaitForPageLoadTimeout, ^{
+ return !web_view.isLoading;
+ });
+ EXPECT_TRUE(success);
Eugene But (OOO till 7-30) 2017/05/19 18:39:49 Should this be ASSERT_TRUE? There is no point in r
michaeldo 2017/05/23 16:20:52 You're right, changed to ASSERT_TRUE.
+}

Powered by Google App Engine
This is Rietveld 408576698