| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/chrome/browser/web/chrome_web_client.h" | 5 #include "ios/chrome/browser/web/chrome_web_client.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/mac/scoped_nsobject.h" | |
| 12 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 13 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 15 #include "ios/web/public/test/fakes/test_browser_state.h" | 14 #include "ios/web/public/test/fakes/test_browser_state.h" |
| 16 #import "ios/web/public/test/js_test_util.h" | 15 #import "ios/web/public/test/js_test_util.h" |
| 17 #include "ios/web/public/test/scoped_testing_web_client.h" | 16 #include "ios/web/public/test/scoped_testing_web_client.h" |
| 18 #include "ios/web/public/test/web_test.h" | 17 #include "ios/web/public/test/web_test.h" |
| 19 #import "ios/web/public/web_view_creation_util.h" | 18 #import "ios/web/public/web_view_creation_util.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "testing/gtest_mac.h" | 20 #include "testing/gtest_mac.h" |
| 22 | 21 |
| 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 23 #error "This file requires ARC support." |
| 24 #endif |
| 25 |
| 23 namespace { | 26 namespace { |
| 24 | 27 |
| 25 // Test fixture for testing ChromeWebClient. | 28 // Test fixture for testing ChromeWebClient. |
| 26 typedef web::WebTest ChromeWebClientTest; | 29 typedef web::WebTest ChromeWebClientTest; |
| 27 | 30 |
| 28 TEST_F(ChromeWebClientTest, UserAgent) { | 31 TEST_F(ChromeWebClientTest, UserAgent) { |
| 29 std::vector<std::string> pieces; | 32 std::vector<std::string> pieces; |
| 30 | 33 |
| 31 // Check if the pieces of the user agent string come in the correct order. | 34 // Check if the pieces of the user agent string come in the correct order. |
| 32 ChromeWebClient web_client; | 35 ChromeWebClient web_client; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 web::ScopedTestingWebClient web_client(base::MakeUnique<ChromeWebClient>()); | 81 web::ScopedTestingWebClient web_client(base::MakeUnique<ChromeWebClient>()); |
| 79 NSString* script = web_client.Get()->GetEarlyPageScript(&browser_state); | 82 NSString* script = web_client.Get()->GetEarlyPageScript(&browser_state); |
| 80 web::ExecuteJavaScript(web_view, script); | 83 web::ExecuteJavaScript(web_view, script); |
| 81 EXPECT_NSEQ(@"object", | 84 EXPECT_NSEQ(@"object", |
| 82 web::ExecuteJavaScript(web_view, @"typeof __gCrWeb.print")); | 85 web::ExecuteJavaScript(web_view, @"typeof __gCrWeb.print")); |
| 83 EXPECT_NSEQ(@"undefined", web::ExecuteJavaScript( | 86 EXPECT_NSEQ(@"undefined", web::ExecuteJavaScript( |
| 84 web_view, @"typeof __gCrWeb.windowOpenFix")); | 87 web_view, @"typeof __gCrWeb.windowOpenFix")); |
| 85 } | 88 } |
| 86 | 89 |
| 87 } // namespace | 90 } // namespace |
| OLD | NEW |