Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: chrome/common/chrome_content_client_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698