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.h> | 7 #include <string.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 // Now test the vector with one element. | 99 // Now test the vector with one element. |
100 content::PepperPluginInfo info1; | 100 content::PepperPluginInfo info1; |
101 info1.version = "1.0.0.0"; | 101 info1.version = "1.0.0.0"; |
102 version_vector.push_back(&info1); | 102 version_vector.push_back(&info1); |
103 | 103 |
104 content::PepperPluginInfo* most_recent = | 104 content::PepperPluginInfo* most_recent = |
105 ChromeContentClient::FindMostRecentPlugin(version_vector); | 105 ChromeContentClient::FindMostRecentPlugin(version_vector); |
106 EXPECT_EQ("1.0.0.0", most_recent->version); | 106 EXPECT_EQ("1.0.0.0", most_recent->version); |
107 | 107 |
108 // Now do the generic test of a complex vector. | |
109 content::PepperPluginInfo info2; | |
110 info2.version = "2.0.0.1"; | |
111 content::PepperPluginInfo info3; | |
112 info3.version = "3.5.6.7"; | |
113 content::PepperPluginInfo info4; | |
114 info4.version = "4.0.0.153"; | |
115 content::PepperPluginInfo info5; | 108 content::PepperPluginInfo info5; |
116 info5.version = "5.0.12.1"; | 109 info5.version = "5.0.12.1"; |
117 content::PepperPluginInfo info6_12; | 110 content::PepperPluginInfo info6_12; |
118 info6_12.version = "6.0.0.12"; | 111 info6_12.version = "6.0.0.12"; |
119 content::PepperPluginInfo info6_13; | 112 content::PepperPluginInfo info6_13; |
120 info6_13.version = "6.0.0.13"; | 113 info6_13.version = "6.0.0.13"; |
121 content::PepperPluginInfo info6_13_d; | |
122 info6_13_d.version = "6.0.0.13"; | |
123 info6_13_d.is_debug = true; | |
124 | 114 |
| 115 // Test highest version is picked. |
125 version_vector.clear(); | 116 version_vector.clear(); |
126 version_vector.push_back(&info4); | |
127 version_vector.push_back(&info2); | |
128 version_vector.push_back(&info6_13); | |
129 version_vector.push_back(&info3); | |
130 version_vector.push_back(&info5); | 117 version_vector.push_back(&info5); |
131 version_vector.push_back(&info6_12); | 118 version_vector.push_back(&info6_12); |
132 version_vector.push_back(&info6_13_d); | 119 version_vector.push_back(&info6_13); |
133 | 120 |
134 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 121 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
135 EXPECT_EQ("6.0.0.13", most_recent->version); | 122 EXPECT_EQ("6.0.0.13", most_recent->version); |
136 EXPECT_EQ(true, most_recent->is_debug); | |
137 | 123 |
138 // Check vector order doesn't matter. | 124 // Test that order does not matter, validates tests below. |
139 version_vector.clear(); | 125 version_vector.clear(); |
140 version_vector.push_back(&info6_13_d); | 126 version_vector.push_back(&info6_13); |
141 version_vector.push_back(&info6_12); | 127 version_vector.push_back(&info6_12); |
142 version_vector.push_back(&info5); | 128 version_vector.push_back(&info5); |
143 version_vector.push_back(&info3); | |
144 version_vector.push_back(&info6_13); | |
145 version_vector.push_back(&info2); | |
146 version_vector.push_back(&info4); | |
147 | 129 |
148 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 130 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
149 EXPECT_EQ("6.0.0.13", most_recent->version); | 131 EXPECT_EQ("6.0.0.13", most_recent->version); |
150 EXPECT_EQ(true, most_recent->is_debug); | |
151 | 132 |
152 // Check higher versions still trump debugger. | 133 // Test real scenarios. |
153 content::PepperPluginInfo info5_d; | 134 content::PepperPluginInfo bundled_flash; |
154 info5_d.version = "5.0.12.1"; | 135 bundled_flash.version = "4.3.2.1"; |
155 info5_d.is_debug = true; | 136 bundled_flash.is_external = false; |
| 137 bundled_flash.is_debug = false; |
| 138 bundled_flash.is_on_local_drive = true; |
| 139 bundled_flash.is_bundled = true; |
| 140 bundled_flash.name = "bundled_flash"; |
156 | 141 |
| 142 content::PepperPluginInfo local_component_flash; |
| 143 local_component_flash.version = "4.3.2.1"; |
| 144 local_component_flash.is_external = false; |
| 145 local_component_flash.is_debug = false; |
| 146 local_component_flash.is_on_local_drive = true; |
| 147 local_component_flash.is_bundled = false; |
| 148 local_component_flash.name = "local_component_flash"; |
| 149 |
| 150 content::PepperPluginInfo network_component_flash; |
| 151 network_component_flash.version = "4.3.2.1"; |
| 152 network_component_flash.is_external = false; |
| 153 network_component_flash.is_debug = false; |
| 154 network_component_flash.is_on_local_drive = false; |
| 155 network_component_flash.is_bundled = false; |
| 156 network_component_flash.name = "network_component_flash"; |
| 157 |
| 158 content::PepperPluginInfo system_flash; |
| 159 system_flash.version = "4.3.2.1"; |
| 160 system_flash.is_external = true; |
| 161 system_flash.is_debug = false; |
| 162 system_flash.is_on_local_drive = true; |
| 163 system_flash.is_bundled = false; |
| 164 system_flash.name = "system_flash"; |
| 165 |
| 166 content::PepperPluginInfo system_debug_flash; |
| 167 system_debug_flash.version = "4.3.2.1"; |
| 168 system_debug_flash.is_external = true; |
| 169 system_debug_flash.is_debug = true; |
| 170 system_debug_flash.is_on_local_drive = false; |
| 171 system_debug_flash.is_bundled = false; |
| 172 system_debug_flash.name = "system_debug_flash"; |
| 173 |
| 174 // The order here should be: |
| 175 // 1. Debug System Flash. |
| 176 // 2. Bundled. |
| 177 // 3. Component update on a local drive. |
| 178 // 4. System Flash. |
| 179 // 5. Component update on a network drive. |
| 180 |
| 181 // Debug beats bundled. |
157 version_vector.clear(); | 182 version_vector.clear(); |
158 version_vector.push_back(&info5_d); | 183 version_vector.push_back(&system_debug_flash); |
159 version_vector.push_back(&info6_12); | 184 version_vector.push_back(&bundled_flash); |
160 | 185 |
161 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); | 186 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
162 EXPECT_EQ("6.0.0.12", most_recent->version); | 187 EXPECT_STREQ("system_debug_flash", most_recent->name.c_str()); |
163 EXPECT_EQ(false, most_recent->is_debug); | 188 |
| 189 // Bundled beats component updated. |
| 190 version_vector.clear(); |
| 191 version_vector.push_back(&bundled_flash); |
| 192 version_vector.push_back(&local_component_flash); |
| 193 |
| 194 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
| 195 EXPECT_STREQ("bundled_flash", most_recent->name.c_str()); |
| 196 |
| 197 // Bundled beats System flash |
| 198 version_vector.clear(); |
| 199 version_vector.push_back(&bundled_flash); |
| 200 version_vector.push_back(&system_flash); |
| 201 |
| 202 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
| 203 EXPECT_STREQ("bundled_flash", most_recent->name.c_str()); |
| 204 |
| 205 // Local component updated beats System Flash. |
| 206 version_vector.clear(); |
| 207 version_vector.push_back(&system_flash); |
| 208 version_vector.push_back(&local_component_flash); |
| 209 |
| 210 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
| 211 EXPECT_STREQ("local_component_flash", most_recent->name.c_str()); |
| 212 |
| 213 // System Flash beats component update on network drive. |
| 214 version_vector.clear(); |
| 215 version_vector.push_back(&network_component_flash); |
| 216 version_vector.push_back(&system_flash); |
| 217 |
| 218 most_recent = ChromeContentClient::FindMostRecentPlugin(version_vector); |
| 219 EXPECT_STREQ("system_flash", most_recent->name.c_str()); |
164 } | 220 } |
165 #endif // defined(ENABLE_PLUGINS) | 221 #endif // defined(ENABLE_PLUGINS) |
166 | 222 |
167 TEST(ChromeContentClientTest, AdditionalSchemes) { | 223 TEST(ChromeContentClientTest, AdditionalSchemes) { |
168 EXPECT_TRUE(url::IsStandard( | 224 EXPECT_TRUE(url::IsStandard( |
169 extensions::kExtensionScheme, | 225 extensions::kExtensionScheme, |
170 url::Component(0, strlen(extensions::kExtensionScheme)))); | 226 url::Component(0, strlen(extensions::kExtensionScheme)))); |
171 | 227 |
172 GURL extension_url( | 228 GURL extension_url( |
173 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); | 229 "chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef/foo.html"); |
174 url::Origin origin(extension_url); | 230 url::Origin origin(extension_url); |
175 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", | 231 EXPECT_EQ("chrome-extension://abcdefghijklmnopqrstuvwxyzabcdef", |
176 origin.Serialize()); | 232 origin.Serialize()); |
177 } | 233 } |
178 | 234 |
179 } // namespace chrome_common | 235 } // namespace chrome_common |
OLD | NEW |