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

Side by Side Diff: chrome/browser/chromeos/customization/customization_document_unittest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/chromeos/customization/customization_document.h" 5 #include "chrome/browser/chromeos/customization/customization_document.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 TEST(StartupCustomizationDocumentTest, BadManifest) { 154 TEST(StartupCustomizationDocumentTest, BadManifest) {
155 system::ScopedFakeStatisticsProvider fake_statistics_provider; 155 system::ScopedFakeStatisticsProvider fake_statistics_provider;
156 StartupCustomizationDocument customization(&fake_statistics_provider, 156 StartupCustomizationDocument customization(&fake_statistics_provider,
157 kBadManifest); 157 kBadManifest);
158 EXPECT_FALSE(customization.IsReady()); 158 EXPECT_FALSE(customization.IsReady());
159 } 159 }
160 160
161 class TestURLFetcherCallback { 161 class TestURLFetcherCallback {
162 public: 162 public:
163 scoped_ptr<net::FakeURLFetcher> CreateURLFetcher( 163 std::unique_ptr<net::FakeURLFetcher> CreateURLFetcher(
164 const GURL& url, 164 const GURL& url,
165 net::URLFetcherDelegate* d, 165 net::URLFetcherDelegate* d,
166 const std::string& response_data, 166 const std::string& response_data,
167 net::HttpStatusCode response_code, 167 net::HttpStatusCode response_code,
168 net::URLRequestStatus::Status status) { 168 net::URLRequestStatus::Status status) {
169 scoped_ptr<net::FakeURLFetcher> fetcher( 169 std::unique_ptr<net::FakeURLFetcher> fetcher(
170 new net::FakeURLFetcher(url, d, response_data, response_code, status)); 170 new net::FakeURLFetcher(url, d, response_data, response_code, status));
171 OnRequestCreate(url, fetcher.get()); 171 OnRequestCreate(url, fetcher.get());
172 return fetcher; 172 return fetcher;
173 } 173 }
174 MOCK_METHOD2(OnRequestCreate, 174 MOCK_METHOD2(OnRequestCreate,
175 void(const GURL&, net::FakeURLFetcher*)); 175 void(const GURL&, net::FakeURLFetcher*));
176 }; 176 };
177 177
178 void AddMimeHeader(const GURL& url, net::FakeURLFetcher* fetcher) { 178 void AddMimeHeader(const GURL& url, net::FakeURLFetcher* fetcher) {
179 scoped_refptr<net::HttpResponseHeaders> download_headers = 179 scoped_refptr<net::HttpResponseHeaders> download_headers =
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 id.c_str())); 271 id.c_str()));
272 factory_.SetFakeResponse(url, 272 factory_.SetFakeResponse(url,
273 std::string(), 273 std::string(),
274 net::HTTP_NOT_FOUND, 274 net::HTTP_NOT_FOUND,
275 net::URLRequestStatus::SUCCESS); 275 net::URLRequestStatus::SUCCESS);
276 EXPECT_CALL(url_callback_, OnRequestCreate(url, _)) 276 EXPECT_CALL(url_callback_, OnRequestCreate(url, _))
277 .Times(Exactly(1)) 277 .Times(Exactly(1))
278 .WillRepeatedly(Invoke(AddMimeHeader)); 278 .WillRepeatedly(Invoke(AddMimeHeader));
279 } 279 }
280 280
281 scoped_ptr<TestingProfile> CreateProfile() { 281 std::unique_ptr<TestingProfile> CreateProfile() {
282 TestingProfile::Builder profile_builder; 282 TestingProfile::Builder profile_builder;
283 syncable_prefs::PrefServiceMockFactory factory; 283 syncable_prefs::PrefServiceMockFactory factory;
284 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( 284 scoped_refptr<user_prefs::PrefRegistrySyncable> registry(
285 new user_prefs::PrefRegistrySyncable); 285 new user_prefs::PrefRegistrySyncable);
286 scoped_ptr<syncable_prefs::PrefServiceSyncable> prefs( 286 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs(
287 factory.CreateSyncable(registry.get())); 287 factory.CreateSyncable(registry.get()));
288 chrome::RegisterUserProfilePrefs(registry.get()); 288 chrome::RegisterUserProfilePrefs(registry.get());
289 profile_builder.SetPrefService(std::move(prefs)); 289 profile_builder.SetPrefService(std::move(prefs));
290 return profile_builder.Build(); 290 return profile_builder.Build();
291 } 291 }
292 292
293 private: 293 private:
294 system::ScopedFakeStatisticsProvider fake_statistics_provider_; 294 system::ScopedFakeStatisticsProvider fake_statistics_provider_;
295 content::TestBrowserThreadBundle thread_bundle_; 295 content::TestBrowserThreadBundle thread_bundle_;
296 TestingPrefServiceSimple local_state_; 296 TestingPrefServiceSimple local_state_;
(...skipping 11 matching lines...) Expand all
308 EXPECT_FALSE(doc->IsReady()); 308 EXPECT_FALSE(doc->IsReady());
309 309
310 doc->StartFetching(); 310 doc->StartFetching();
311 RunUntilIdle(); 311 RunUntilIdle();
312 EXPECT_TRUE(doc->IsReady()); 312 EXPECT_TRUE(doc->IsReady());
313 313
314 GURL wallpaper_url; 314 GURL wallpaper_url;
315 EXPECT_FALSE(doc->GetDefaultWallpaperUrl(&wallpaper_url)); 315 EXPECT_FALSE(doc->GetDefaultWallpaperUrl(&wallpaper_url));
316 EXPECT_EQ("", wallpaper_url.spec()); 316 EXPECT_EQ("", wallpaper_url.spec());
317 317
318 scoped_ptr<base::DictionaryValue> default_apps(doc->GetDefaultApps()); 318 std::unique_ptr<base::DictionaryValue> default_apps(doc->GetDefaultApps());
319 ASSERT_TRUE(default_apps); 319 ASSERT_TRUE(default_apps);
320 EXPECT_EQ(default_apps->size(), 2u); 320 EXPECT_EQ(default_apps->size(), 2u);
321 321
322 const base::DictionaryValue* app_entry = nullptr; 322 const base::DictionaryValue* app_entry = nullptr;
323 ASSERT_TRUE(default_apps->GetDictionary("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 323 ASSERT_TRUE(default_apps->GetDictionary("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
324 &app_entry)); 324 &app_entry));
325 EXPECT_EQ(app_entry->size(), 1u); 325 EXPECT_EQ(app_entry->size(), 1u);
326 EXPECT_TRUE( 326 EXPECT_TRUE(
327 app_entry->HasKey(extensions::ExternalProviderImpl::kExternalUpdateUrl)); 327 app_entry->HasKey(extensions::ExternalProviderImpl::kExternalUpdateUrl));
328 328
329 ASSERT_TRUE(default_apps->GetDictionary("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 329 ASSERT_TRUE(default_apps->GetDictionary("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
330 &app_entry)); 330 &app_entry));
331 EXPECT_EQ(app_entry->size(), 2u); 331 EXPECT_EQ(app_entry->size(), 2u);
332 EXPECT_TRUE( 332 EXPECT_TRUE(
333 app_entry->HasKey(extensions::ExternalProviderImpl::kExternalUpdateUrl)); 333 app_entry->HasKey(extensions::ExternalProviderImpl::kExternalUpdateUrl));
334 EXPECT_TRUE(app_entry->HasKey( 334 EXPECT_TRUE(app_entry->HasKey(
335 extensions::ExternalProviderImpl::kDoNotInstallForEnterprise)); 335 extensions::ExternalProviderImpl::kDoNotInstallForEnterprise));
336 336
337 EXPECT_EQ("EN-US OEM Name", doc->GetOemAppsFolderName("en-US")); 337 EXPECT_EQ("EN-US OEM Name", doc->GetOemAppsFolderName("en-US"));
338 EXPECT_EQ("EN OEM Name", doc->GetOemAppsFolderName("en")); 338 EXPECT_EQ("EN OEM Name", doc->GetOemAppsFolderName("en"));
339 EXPECT_EQ("Default OEM Name", doc->GetOemAppsFolderName("ru")); 339 EXPECT_EQ("Default OEM Name", doc->GetOemAppsFolderName("ru"));
340 } 340 }
341 341
342 TEST_F(ServicesCustomizationDocumentTest, NoCustomizationIdInVpd) { 342 TEST_F(ServicesCustomizationDocumentTest, NoCustomizationIdInVpd) {
343 ServicesCustomizationDocument* doc = 343 ServicesCustomizationDocument* doc =
344 ServicesCustomizationDocument::GetInstance(); 344 ServicesCustomizationDocument::GetInstance();
345 EXPECT_FALSE(doc->IsReady()); 345 EXPECT_FALSE(doc->IsReady());
346 346
347 scoped_ptr<TestingProfile> profile = CreateProfile(); 347 std::unique_ptr<TestingProfile> profile = CreateProfile();
348 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get()); 348 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get());
349 EXPECT_TRUE(loader); 349 EXPECT_TRUE(loader);
350 350
351 MockExternalProviderVisitor visitor; 351 MockExternalProviderVisitor visitor;
352 scoped_ptr<extensions::ExternalProviderImpl> provider( 352 std::unique_ptr<extensions::ExternalProviderImpl> provider(
353 new extensions::ExternalProviderImpl( 353 new extensions::ExternalProviderImpl(
354 &visitor, 354 &visitor, loader, profile.get(), extensions::Manifest::EXTERNAL_PREF,
355 loader,
356 profile.get(),
357 extensions::Manifest::EXTERNAL_PREF,
358 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, 355 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD,
359 extensions::Extension::FROM_WEBSTORE | 356 extensions::Extension::FROM_WEBSTORE |
360 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); 357 extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
361 358
362 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); 359 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
363 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); 360 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
364 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 361 EXPECT_CALL(visitor, OnExternalProviderReady(_))
365 .Times(1); 362 .Times(1);
366 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); 363 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
367 364
368 // Manually request a load. 365 // Manually request a load.
369 RunUntilIdle(); 366 RunUntilIdle();
370 loader->StartLoading(); 367 loader->StartLoading();
371 Mock::VerifyAndClearExpectations(&visitor); 368 Mock::VerifyAndClearExpectations(&visitor);
372 369
373 RunUntilIdle(); 370 RunUntilIdle();
374 // Empty customization is used when there is no customization ID in VPD. 371 // Empty customization is used when there is no customization ID in VPD.
375 EXPECT_TRUE(doc->IsReady()); 372 EXPECT_TRUE(doc->IsReady());
376 } 373 }
377 374
378 TEST_F(ServicesCustomizationDocumentTest, DefaultApps) { 375 TEST_F(ServicesCustomizationDocumentTest, DefaultApps) {
379 AddCustomizationIdToVp(kDummyCustomizationID); 376 AddCustomizationIdToVp(kDummyCustomizationID);
380 AddExpectedManifest(kDummyCustomizationID, kGoodServicesManifest); 377 AddExpectedManifest(kDummyCustomizationID, kGoodServicesManifest);
381 378
382 ServicesCustomizationDocument* doc = 379 ServicesCustomizationDocument* doc =
383 ServicesCustomizationDocument::GetInstance(); 380 ServicesCustomizationDocument::GetInstance();
384 EXPECT_FALSE(doc->IsReady()); 381 EXPECT_FALSE(doc->IsReady());
385 382
386 scoped_ptr<TestingProfile> profile = CreateProfile(); 383 std::unique_ptr<TestingProfile> profile = CreateProfile();
387 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get()); 384 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get());
388 EXPECT_TRUE(loader); 385 EXPECT_TRUE(loader);
389 386
390 app_list::AppListSyncableServiceFactory::GetInstance()-> 387 app_list::AppListSyncableServiceFactory::GetInstance()->
391 SetTestingFactoryAndUse( 388 SetTestingFactoryAndUse(
392 profile.get(), 389 profile.get(),
393 &app_list::AppListSyncableServiceFactory::BuildInstanceFor); 390 &app_list::AppListSyncableServiceFactory::BuildInstanceFor);
394 391
395 MockExternalProviderVisitor visitor; 392 MockExternalProviderVisitor visitor;
396 scoped_ptr<extensions::ExternalProviderImpl> provider( 393 std::unique_ptr<extensions::ExternalProviderImpl> provider(
397 new extensions::ExternalProviderImpl( 394 new extensions::ExternalProviderImpl(
398 &visitor, 395 &visitor, loader, profile.get(), extensions::Manifest::EXTERNAL_PREF,
399 loader,
400 profile.get(),
401 extensions::Manifest::EXTERNAL_PREF,
402 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, 396 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD,
403 extensions::Extension::FROM_WEBSTORE | 397 extensions::Extension::FROM_WEBSTORE |
404 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); 398 extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
405 399
406 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); 400 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
407 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); 401 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
408 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 402 EXPECT_CALL(visitor, OnExternalProviderReady(_))
409 .Times(1); 403 .Times(1);
410 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); 404 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
411 405
(...skipping 17 matching lines...) Expand all
429 } 423 }
430 424
431 TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) { 425 TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) {
432 AddCustomizationIdToVp(kDummyCustomizationID); 426 AddCustomizationIdToVp(kDummyCustomizationID);
433 AddManifestNotFound(kDummyCustomizationID); 427 AddManifestNotFound(kDummyCustomizationID);
434 428
435 ServicesCustomizationDocument* doc = 429 ServicesCustomizationDocument* doc =
436 ServicesCustomizationDocument::GetInstance(); 430 ServicesCustomizationDocument::GetInstance();
437 EXPECT_FALSE(doc->IsReady()); 431 EXPECT_FALSE(doc->IsReady());
438 432
439 scoped_ptr<TestingProfile> profile = CreateProfile(); 433 std::unique_ptr<TestingProfile> profile = CreateProfile();
440 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get()); 434 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get());
441 EXPECT_TRUE(loader); 435 EXPECT_TRUE(loader);
442 436
443 MockExternalProviderVisitor visitor; 437 MockExternalProviderVisitor visitor;
444 scoped_ptr<extensions::ExternalProviderImpl> provider( 438 std::unique_ptr<extensions::ExternalProviderImpl> provider(
445 new extensions::ExternalProviderImpl( 439 new extensions::ExternalProviderImpl(
446 &visitor, 440 &visitor, loader, profile.get(), extensions::Manifest::EXTERNAL_PREF,
447 loader,
448 profile.get(),
449 extensions::Manifest::EXTERNAL_PREF,
450 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, 441 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD,
451 extensions::Extension::FROM_WEBSTORE | 442 extensions::Extension::FROM_WEBSTORE |
452 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); 443 extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
453 444
454 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); 445 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
455 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); 446 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
456 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 447 EXPECT_CALL(visitor, OnExternalProviderReady(_))
457 .Times(1); 448 .Times(1);
458 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); 449 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
459 450
460 // Manually request a load. 451 // Manually request a load.
461 loader->StartLoading(); 452 loader->StartLoading();
462 Mock::VerifyAndClearExpectations(&visitor); 453 Mock::VerifyAndClearExpectations(&visitor);
463 454
464 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); 455 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
465 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); 456 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
466 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 457 EXPECT_CALL(visitor, OnExternalProviderReady(_))
467 .Times(1); 458 .Times(1);
468 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); 459 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
469 460
470 RunUntilIdle(); 461 RunUntilIdle();
471 EXPECT_TRUE(doc->IsReady()); 462 EXPECT_TRUE(doc->IsReady());
472 } 463 }
473 464
474 } // namespace chromeos 465 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698