| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Test fixture for testing ChromeWebClient. | 25 // Test fixture for testing ChromeWebClient. |
| 26 typedef web::WebTest ChromeWebClientTest; | 26 typedef web::WebTest ChromeWebClientTest; |
| 27 | 27 |
| 28 TEST_F(ChromeWebClientTest, UserAgent) { | 28 TEST_F(ChromeWebClientTest, UserAgent) { |
| 29 std::vector<std::string> pieces; | 29 std::vector<std::string> pieces; |
| 30 | 30 |
| 31 // Check if the pieces of the user agent string come in the correct order. | 31 // Check if the pieces of the user agent string come in the correct order. |
| 32 ChromeWebClient web_client; | 32 ChromeWebClient web_client; |
| 33 std::string buffer = web_client.GetUserAgent(false); | 33 std::string buffer = web_client.GetUserAgent(web::UserAgentType::MOBILE); |
| 34 | 34 |
| 35 pieces = base::SplitStringUsingSubstr( | 35 pieces = base::SplitStringUsingSubstr( |
| 36 buffer, "Mozilla/5.0 (", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 36 buffer, "Mozilla/5.0 (", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 37 ASSERT_EQ(2u, pieces.size()); | 37 ASSERT_EQ(2u, pieces.size()); |
| 38 buffer = pieces[1]; | 38 buffer = pieces[1]; |
| 39 EXPECT_EQ("", pieces[0]); | 39 EXPECT_EQ("", pieces[0]); |
| 40 | 40 |
| 41 pieces = base::SplitStringUsingSubstr( | 41 pieces = base::SplitStringUsingSubstr( |
| 42 buffer, ") AppleWebKit/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 42 buffer, ") AppleWebKit/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 43 ASSERT_EQ(2u, pieces.size()); | 43 ASSERT_EQ(2u, pieces.size()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 web::ScopedTestingWebClient web_client(base::MakeUnique<ChromeWebClient>()); | 78 web::ScopedTestingWebClient web_client(base::MakeUnique<ChromeWebClient>()); |
| 79 NSString* script = web_client.Get()->GetEarlyPageScript(); | 79 NSString* script = web_client.Get()->GetEarlyPageScript(); |
| 80 web::ExecuteJavaScript(web_view, script); | 80 web::ExecuteJavaScript(web_view, script); |
| 81 EXPECT_NSEQ(@"object", | 81 EXPECT_NSEQ(@"object", |
| 82 web::ExecuteJavaScript(web_view, @"typeof __gCrWeb.print")); | 82 web::ExecuteJavaScript(web_view, @"typeof __gCrWeb.print")); |
| 83 EXPECT_NSEQ(@"undefined", web::ExecuteJavaScript( | 83 EXPECT_NSEQ(@"undefined", web::ExecuteJavaScript( |
| 84 web_view, @"typeof __gCrWeb.windowOpenFix")); | 84 web_view, @"typeof __gCrWeb.windowOpenFix")); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace | 87 } // namespace |
| OLD | NEW |