| 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/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // Test that order does not matter, validates tests below. | 131 // Test that order does not matter, validates tests below. |
| 132 version_vector.clear(); | 132 version_vector.clear(); |
| 133 version_vector.push_back(&info6_13); | 133 version_vector.push_back(&info6_13); |
| 134 version_vector.push_back(&info6_12); | 134 version_vector.push_back(&info6_12); |
| 135 version_vector.push_back(&info5); | 135 version_vector.push_back(&info5); |
| 136 | 136 |
| 137 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 137 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
| 138 EXPECT_EQ("6.0.0.13", most_recent->version); | 138 EXPECT_EQ("6.0.0.13", most_recent->version); |
| 139 | 139 |
| 140 // Test real scenarios. | 140 // Test real scenarios. |
| 141 content::PepperPluginInfo bundled_flash; | 141 content::PepperPluginInfo component_flash; |
| 142 bundled_flash.version = "4.3.2.1"; | 142 component_flash.version = "4.3.2.1"; |
| 143 bundled_flash.is_external = false; | 143 component_flash.is_external = false; |
| 144 bundled_flash.is_debug = false; | 144 component_flash.name = "component_flash"; |
| 145 bundled_flash.is_on_local_drive = true; | |
| 146 bundled_flash.is_bundled = true; | |
| 147 bundled_flash.name = "bundled_flash"; | |
| 148 | |
| 149 content::PepperPluginInfo local_component_flash; | |
| 150 local_component_flash.version = "4.3.2.1"; | |
| 151 local_component_flash.is_external = false; | |
| 152 local_component_flash.is_debug = false; | |
| 153 local_component_flash.is_on_local_drive = true; | |
| 154 local_component_flash.is_bundled = false; | |
| 155 local_component_flash.name = "local_component_flash"; | |
| 156 | |
| 157 content::PepperPluginInfo network_component_flash; | |
| 158 network_component_flash.version = "4.3.2.1"; | |
| 159 network_component_flash.is_external = false; | |
| 160 network_component_flash.is_debug = false; | |
| 161 network_component_flash.is_on_local_drive = false; | |
| 162 network_component_flash.is_bundled = false; | |
| 163 network_component_flash.name = "network_component_flash"; | |
| 164 | 145 |
| 165 content::PepperPluginInfo system_flash; | 146 content::PepperPluginInfo system_flash; |
| 166 system_flash.version = "4.3.2.1"; | 147 system_flash.version = "4.3.2.1"; |
| 167 system_flash.is_external = true; | 148 system_flash.is_external = true; |
| 168 system_flash.is_debug = false; | |
| 169 system_flash.is_on_local_drive = true; | |
| 170 system_flash.is_bundled = false; | |
| 171 system_flash.name = "system_flash"; | 149 system_flash.name = "system_flash"; |
| 172 | 150 |
| 173 content::PepperPluginInfo system_debug_flash; | |
| 174 system_debug_flash.version = "4.3.2.1"; | |
| 175 system_debug_flash.is_external = true; | |
| 176 system_debug_flash.is_debug = true; | |
| 177 system_debug_flash.is_on_local_drive = false; | |
| 178 system_debug_flash.is_bundled = false; | |
| 179 system_debug_flash.name = "system_debug_flash"; | |
| 180 | |
| 181 // The order here should be: | 151 // The order here should be: |
| 182 // 1. Debug System Flash. | 152 // 1. System Flash. |
| 183 // 2. Bundled. | 153 // 2. Component update. |
| 184 // 3. Component update on a local drive. | |
| 185 // 4. System Flash. | |
| 186 // 5. Component update on a network drive. | |
| 187 | |
| 188 // Debug beats bundled. | |
| 189 version_vector.clear(); | |
| 190 version_vector.push_back(&system_debug_flash); | |
| 191 version_vector.push_back(&bundled_flash); | |
| 192 | |
| 193 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
| 194 EXPECT_STREQ("system_debug_flash", most_recent->name.c_str()); | |
| 195 | |
| 196 // Bundled beats component updated. | |
| 197 version_vector.clear(); | |
| 198 version_vector.push_back(&bundled_flash); | |
| 199 version_vector.push_back(&local_component_flash); | |
| 200 | |
| 201 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
| 202 EXPECT_STREQ("bundled_flash", most_recent->name.c_str()); | |
| 203 | |
| 204 // Bundled beats System flash | |
| 205 version_vector.clear(); | |
| 206 version_vector.push_back(&bundled_flash); | |
| 207 version_vector.push_back(&system_flash); | |
| 208 | |
| 209 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
| 210 EXPECT_STREQ("bundled_flash", most_recent->name.c_str()); | |
| 211 | |
| 212 // Local component updated beats System Flash. | |
| 213 version_vector.clear(); | 154 version_vector.clear(); |
| 214 version_vector.push_back(&system_flash); | 155 version_vector.push_back(&system_flash); |
| 215 version_vector.push_back(&local_component_flash); | 156 version_vector.push_back(&component_flash); |
| 216 | |
| 217 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | |
| 218 EXPECT_STREQ("local_component_flash", most_recent->name.c_str()); | |
| 219 | |
| 220 // System Flash beats component update on network drive. | |
| 221 version_vector.clear(); | |
| 222 version_vector.push_back(&network_component_flash); | |
| 223 version_vector.push_back(&system_flash); | |
| 224 | |
| 225 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 157 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
| 226 EXPECT_STREQ("system_flash", most_recent->name.c_str()); | 158 EXPECT_STREQ("system_flash", most_recent->name.c_str()); |
| 227 } | 159 } |
| 228 #endif // defined(ENABLE_PLUGINS) | 160 #endif // defined(ENABLE_PLUGINS) |
| 229 | 161 |
| 230 TEST(ChromeContentClientTest, AdditionalSchemes) { | 162 TEST(ChromeContentClientTest, AdditionalSchemes) { |
| 231 EXPECT_TRUE(url::IsStandard( | 163 EXPECT_TRUE(url::IsStandard( |
| 232 extensions::kExtensionScheme, | 164 extensions::kExtensionScheme, |
| 233 url::Component(0, strlen(extensions::kExtensionScheme)))); | 165 url::Component(0, strlen(extensions::kExtensionScheme)))); |
| 234 | 166 |
| 235 GURL extension_url( | 167 GURL extension_url( |
| 236 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); | 168 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); |
| 237 url::Origin origin(extension_url); | 169 url::Origin origin(extension_url); |
| 238 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", | 170 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", |
| 239 origin.Serialize()); | 171 origin.Serialize()); |
| 240 } | 172 } |
| 241 | 173 |
| 242 } // namespace chrome_common | 174 } // namespace chrome_common |
| OLD | NEW |