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

Unified Diff: ios/web/web_state/ui/web_view_js_utils_unittest.mm

Issue 1641893003: [ios] Removed WEB_TEST_F from web unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged with origin Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller_unittest.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/web_view_js_utils_unittest.mm
diff --git a/ios/web/web_state/ui/web_view_js_utils_unittest.mm b/ios/web/web_state/ui/web_view_js_utils_unittest.mm
index b0f699e61621d33e54edefe3f613843353fb2f75..8a0bde324d4f9148b2cd87a9020e8d6ce49b0603 100644
--- a/ios/web/web_state/ui/web_view_js_utils_unittest.mm
+++ b/ios/web/web_state/ui/web_view_js_utils_unittest.mm
@@ -9,85 +9,68 @@
#include "base/test/ios/wait_util.h"
#include "ios/web/public/test/test_browser_state.h"
#import "ios/web/public/test/test_web_client.h"
-#include "ios/web/public/test/web_test_util.h"
#import "ios/web/public/web_view_creation_util.h"
#import "ios/web/web_state/web_view_internal_creation_util.h"
#import "ios/web/test/web_test.h"
#include "testing/gtest_mac.h"
#include "testing/platform_test.h"
-namespace {
+namespace web {
-// Synchronously returns result of web::EvaluateJavaScript call.
-template <typename WebView>
-NSString* EvaluateJavaScript(WebView web_view, NSString* js) {
- __block bool evaluation_completed = false;
- __block base::scoped_nsobject<NSString> evaluation_result;
- web::EvaluateJavaScript(web_view, js, ^(NSString* result, NSError* error) {
+// Test fixture for web::EvaluateJavaScript testing.
+class WebViewJsUtilsTest : public web::WebTest {
+ protected:
+ void SetUp() override {
+ web::WebTest::SetUp();
+ web_view_.reset(web::CreateWKWebView(CGRectZero, GetBrowserState()));
+ }
+ // Synchronously returns result of web::EvaluateJavaScript call.
+ NSString* EvaluateJavaScript(NSString* js) {
+ __block bool evaluation_completed = false;
+ __block base::scoped_nsobject<NSString> evaluation_result;
+ web::EvaluateJavaScript(web_view_, js, ^(NSString* result, NSError* error) {
DCHECK(!error);
evaluation_result.reset([result copy]);
evaluation_completed = true;
- });
- base::test::ios::WaitUntilCondition(^bool() {
- return evaluation_completed;
- });
- return [[evaluation_result copy] autorelease];
-}
-
-// Base test fixture for web::EvaluateJavaScript testing.
-typedef web::WebTest WebViewJSUtilsTest;
-
-// Test fixture for web::EvaluateJavaScript(UIWebView*..) testing.
-class UIWebViewJSUtilsTest : public WebViewJSUtilsTest {
- protected:
- void SetUp() override {
- WebViewJSUtilsTest::SetUp();
- web_view_.reset(web::CreateWebView(CGRectZero));
+ });
+ base::test::ios::WaitUntilCondition(^{
+ return evaluation_completed;
+ });
+ return [[evaluation_result copy] autorelease];
}
- // UIWebView created for testing.
- base::scoped_nsobject<UIWebView> web_view_;
-};
-// Test fixture for web::EvaluateJavaScript(WKWebView*..) testing.
-class WKWebViewJSUtilsTest : public WebViewJSUtilsTest {
- protected:
- void SetUp() override {
- // SetUp crashes on iOS 7.
- CR_TEST_REQUIRES_WK_WEB_VIEW();
- WebViewJSUtilsTest::SetUp();
- web_view_.reset(web::CreateWKWebView(CGRectZero, GetBrowserState()));
- }
+ private:
// WKWebView created for testing.
base::scoped_nsobject<WKWebView> web_view_;
};
// Tests that a script with undefined result correctly evaluates to string.
-WEB_TEST_F(UIWebViewJSUtilsTest, WKWebViewJSUtilsTest, UndefinedEvaluation) {
- EXPECT_NSEQ(@"", EvaluateJavaScript(this->web_view_, @"{}"));
+TEST_F(WebViewJsUtilsTest, UndefinedEvaluation) {
+ EXPECT_NSEQ(@"", EvaluateJavaScript(@"{}"));
}
// Tests that a script with string result correctly evaluates to string.
-WEB_TEST_F(UIWebViewJSUtilsTest, WKWebViewJSUtilsTest, StringEvaluation) {
- EXPECT_NSEQ(@"test", EvaluateJavaScript(this->web_view_, @"'test'"));
+TEST_F(WebViewJsUtilsTest, StringEvaluation) {
+ EXPECT_NSEQ(@"test", EvaluateJavaScript(@"'test'"));
}
// Tests that a script with number result correctly evaluates to string.
-WEB_TEST_F(UIWebViewJSUtilsTest, WKWebViewJSUtilsTest, NumberEvaluation) {
- EXPECT_NSEQ(@"-1", EvaluateJavaScript(this->web_view_, @"-1"));
- EXPECT_NSEQ(@"0", EvaluateJavaScript(this->web_view_, @"0"));
- EXPECT_NSEQ(@"1", EvaluateJavaScript(this->web_view_, @"1"));
- EXPECT_NSEQ(@"3.14", EvaluateJavaScript(this->web_view_, @"3.14"));
+TEST_F(WebViewJsUtilsTest, NumberEvaluation) {
+ EXPECT_NSEQ(@"-1", EvaluateJavaScript(@"-1"));
+ EXPECT_NSEQ(@"0", EvaluateJavaScript(@"0"));
+ EXPECT_NSEQ(@"1", EvaluateJavaScript(@"1"));
+ EXPECT_NSEQ(@"3.14", EvaluateJavaScript(@"3.14"));
}
// Tests that a script with bool result correctly evaluates to string.
-WEB_TEST_F(UIWebViewJSUtilsTest, WKWebViewJSUtilsTest, BoolEvaluation) {
- EXPECT_NSEQ(@"true", EvaluateJavaScript(this->web_view_, @"true"));
- EXPECT_NSEQ(@"false", EvaluateJavaScript(this->web_view_, @"false"));
+TEST_F(WebViewJsUtilsTest, BoolEvaluation) {
+ EXPECT_NSEQ(@"true", EvaluateJavaScript(@"true"));
+ EXPECT_NSEQ(@"false", EvaluateJavaScript(@"false"));
}
// Tests that a script with null result correctly evaluates to empty string.
-WEB_TEST_F(UIWebViewJSUtilsTest, WKWebViewJSUtilsTest, NullEvaluation) {
- EXPECT_NSEQ(@"", EvaluateJavaScript(this->web_view_, @"null"));
+TEST_F(WebViewJsUtilsTest, NullEvaluation) {
+ EXPECT_NSEQ(@"", EvaluateJavaScript(@"null"));
}
-} // namespace
+} // namespace web
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698