| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/chrome_content_client.h" | 5 #include "chrome/common/chrome_content_client.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/test/scoped_command_line.h" | 12 #include "base/test/scoped_command_line.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
| 16 #include "ppapi/features/features.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 18 #include "url/origin.h" | 19 #include "url/origin.h" |
| 19 #include "url/url_util.h" | 20 #include "url/url_util.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 void CheckUserAgentStringOrdering(bool mobile_device) { | 24 void CheckUserAgentStringOrdering(bool mobile_device) { |
| 24 std::vector<std::string> pieces; | 25 std::vector<std::string> pieces; |
| 25 | 26 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 // Do it for mobile devices. | 93 // Do it for mobile devices. |
| 93 command_line->AppendSwitch(switches::kUseMobileUserAgent); | 94 command_line->AppendSwitch(switches::kUseMobileUserAgent); |
| 94 ASSERT_TRUE(command_line->HasSwitch(switches::kUseMobileUserAgent)); | 95 ASSERT_TRUE(command_line->HasSwitch(switches::kUseMobileUserAgent)); |
| 95 CheckUserAgentStringOrdering(true); | 96 CheckUserAgentStringOrdering(true); |
| 96 #else | 97 #else |
| 97 CheckUserAgentStringOrdering(false); | 98 CheckUserAgentStringOrdering(false); |
| 98 #endif | 99 #endif |
| 99 } | 100 } |
| 100 | 101 |
| 101 #if defined(ENABLE_PLUGINS) | 102 #if BUILDFLAG(ENABLE_PLUGINS) |
| 102 TEST(ChromeContentClientTest, FindMostRecent) { | 103 TEST(ChromeContentClientTest, FindMostRecent) { |
| 103 std::vector<std::unique_ptr<content::PepperPluginInfo>> version_vector; | 104 std::vector<std::unique_ptr<content::PepperPluginInfo>> version_vector; |
| 104 // Test an empty vector. | 105 // Test an empty vector. |
| 105 EXPECT_EQ(nullptr, ChromeContentClient::FindMostRecentPlugin(version_vector)); | 106 EXPECT_EQ(nullptr, ChromeContentClient::FindMostRecentPlugin(version_vector)); |
| 106 | 107 |
| 107 // Now test the vector with one element. | 108 // Now test the vector with one element. |
| 108 content::PepperPluginInfo info; | 109 content::PepperPluginInfo info; |
| 109 info.version = "1.0.0.0"; | 110 info.version = "1.0.0.0"; |
| 110 version_vector.push_back(base::MakeUnique<content::PepperPluginInfo>(info)); | 111 version_vector.push_back(base::MakeUnique<content::PepperPluginInfo>(info)); |
| 111 | 112 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // 1. System Flash. | 158 // 1. System Flash. |
| 158 // 2. Component update. | 159 // 2. Component update. |
| 159 version_vector.clear(); | 160 version_vector.clear(); |
| 160 version_vector.push_back( | 161 version_vector.push_back( |
| 161 base::MakeUnique<content::PepperPluginInfo>(system_flash)); | 162 base::MakeUnique<content::PepperPluginInfo>(system_flash)); |
| 162 version_vector.push_back( | 163 version_vector.push_back( |
| 163 base::MakeUnique<content::PepperPluginInfo>(component_flash)); | 164 base::MakeUnique<content::PepperPluginInfo>(component_flash)); |
| 164 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 165 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
| 165 EXPECT_STREQ("system_flash", most_recent->name.c_str()); | 166 EXPECT_STREQ("system_flash", most_recent->name.c_str()); |
| 166 } | 167 } |
| 167 #endif // defined(ENABLE_PLUGINS) | 168 #endif // BUILDFLAG(ENABLE_PLUGINS) |
| 168 | 169 |
| 169 TEST(ChromeContentClientTest, AdditionalSchemes) { | 170 TEST(ChromeContentClientTest, AdditionalSchemes) { |
| 170 EXPECT_TRUE(url::IsStandard( | 171 EXPECT_TRUE(url::IsStandard( |
| 171 extensions::kExtensionScheme, | 172 extensions::kExtensionScheme, |
| 172 url::Component(0, strlen(extensions::kExtensionScheme)))); | 173 url::Component(0, strlen(extensions::kExtensionScheme)))); |
| 173 | 174 |
| 174 GURL extension_url( | 175 GURL extension_url( |
| 175 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); | 176 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); |
| 176 url::Origin origin(extension_url); | 177 url::Origin origin(extension_url); |
| 177 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", | 178 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", |
| 178 origin.Serialize()); | 179 origin.Serialize()); |
| 179 } | 180 } |
| 180 | 181 |
| 181 } // namespace chrome_common | 182 } // namespace chrome_common |
| OLD | NEW |