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

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

Issue 1495403002: Observe adding external extensions via windows registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing files Created 4 years, 11 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/prefs/testing_pref_service.h" 10 #include "base/prefs/testing_pref_service.h"
(...skipping 21 matching lines...) Expand all
32 #include "net/http/http_status_code.h" 32 #include "net/http/http_status_code.h"
33 #include "net/url_request/test_url_fetcher_factory.h" 33 #include "net/url_request/test_url_fetcher_factory.h"
34 #include "net/url_request/url_request_status.h" 34 #include "net/url_request/url_request_status.h"
35 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
36 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
37 37
38 using ::testing::Exactly; 38 using ::testing::Exactly;
39 using ::testing::Invoke; 39 using ::testing::Invoke;
40 using ::testing::Mock; 40 using ::testing::Mock;
41 using ::testing::_; 41 using ::testing::_;
42 using extensions::ExternalExtensionInstallInfoFile;
43 using extensions::ExternalExtensionInstallInfoUpdateUrl;
42 44
43 namespace { 45 namespace {
44 46
45 const char kGoodStartupManifest[] = 47 const char kGoodStartupManifest[] =
46 "{" 48 "{"
47 " \"version\": \"1.0\"," 49 " \"version\": \"1.0\","
48 " \"initial_locale\" : \"en-US\"," 50 " \"initial_locale\" : \"en-US\","
49 " \"initial_timezone\" : \"US/Pacific\"," 51 " \"initial_timezone\" : \"US/Pacific\","
50 " \"keyboard_layout\" : \"xkb:us::eng\"," 52 " \"keyboard_layout\" : \"xkb:us::eng\","
51 " \"setup_content\" : {" 53 " \"setup_content\" : {"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 new net::HttpResponseHeaders(""); 179 new net::HttpResponseHeaders("");
178 download_headers->AddHeader("Content-Type: application/json"); 180 download_headers->AddHeader("Content-Type: application/json");
179 fetcher->set_response_headers(download_headers); 181 fetcher->set_response_headers(download_headers);
180 } 182 }
181 183
182 class MockExternalProviderVisitor 184 class MockExternalProviderVisitor
183 : public extensions::ExternalProviderInterface::VisitorInterface { 185 : public extensions::ExternalProviderInterface::VisitorInterface {
184 public: 186 public:
185 MockExternalProviderVisitor() {} 187 MockExternalProviderVisitor() {}
186 188
187 MOCK_METHOD7(OnExternalExtensionFileFound, 189 MOCK_METHOD1(OnExternalExtensionFileFound,
188 bool(const std::string&, 190 bool(ExternalExtensionInstallInfoFile*));
189 const base::Version*, 191 MOCK_METHOD2(OnExternalExtensionUpdateUrlFound,
190 const base::FilePath&, 192 bool(ExternalExtensionInstallInfoUpdateUrl*, bool));
191 extensions::Manifest::Location,
192 int,
193 bool,
194 bool));
195 MOCK_METHOD6(OnExternalExtensionUpdateUrlFound,
196 bool(const std::string&,
197 const std::string&,
198 const GURL&,
199 extensions::Manifest::Location,
200 int,
201 bool));
202 MOCK_METHOD1(OnExternalProviderReady, 193 MOCK_METHOD1(OnExternalProviderReady,
203 void(const extensions::ExternalProviderInterface* provider)); 194 void(const extensions::ExternalProviderInterface* provider));
195 MOCK_METHOD4(OnExternalProviderUpdateComplete,
196 void(const extensions::ExternalProviderInterface*,
197 const ScopedVector<ExternalExtensionInstallInfoUpdateUrl>&,
198 const ScopedVector<ExternalExtensionInstallInfoFile>&,
199 const std::set<std::string>& removed_extensions));
204 }; 200 };
205 201
206 class ServicesCustomizationDocumentTest : public testing::Test { 202 class ServicesCustomizationDocumentTest : public testing::Test {
207 protected: 203 protected:
208 ServicesCustomizationDocumentTest() 204 ServicesCustomizationDocumentTest()
209 : factory_(nullptr, 205 : factory_(nullptr,
210 base::Bind(&TestURLFetcherCallback::CreateURLFetcher, 206 base::Bind(&TestURLFetcherCallback::CreateURLFetcher,
211 base::Unretained(&url_callback_))) {} 207 base::Unretained(&url_callback_))) {}
212 208
213 // testing::Test: 209 // testing::Test:
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 scoped_ptr<extensions::ExternalProviderImpl> provider( 351 scoped_ptr<extensions::ExternalProviderImpl> provider(
356 new extensions::ExternalProviderImpl( 352 new extensions::ExternalProviderImpl(
357 &visitor, 353 &visitor,
358 loader, 354 loader,
359 profile.get(), 355 profile.get(),
360 extensions::Manifest::EXTERNAL_PREF, 356 extensions::Manifest::EXTERNAL_PREF,
361 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, 357 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD,
362 extensions::Extension::FROM_WEBSTORE | 358 extensions::Extension::FROM_WEBSTORE |
363 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); 359 extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
364 360
365 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) 361 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
366 .Times(0); 362 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
367 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
368 .Times(0);
369 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 363 EXPECT_CALL(visitor, OnExternalProviderReady(_))
370 .Times(1); 364 .Times(1);
365 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
371 366
372 // Manually request a load. 367 // Manually request a load.
373 RunUntilIdle(); 368 RunUntilIdle();
374 loader->StartLoading(); 369 loader->StartLoading();
375 Mock::VerifyAndClearExpectations(&visitor); 370 Mock::VerifyAndClearExpectations(&visitor);
376 371
377 RunUntilIdle(); 372 RunUntilIdle();
378 // Empty customization is used when there is no customization ID in VPD. 373 // Empty customization is used when there is no customization ID in VPD.
379 EXPECT_TRUE(doc->IsReady()); 374 EXPECT_TRUE(doc->IsReady());
380 } 375 }
(...skipping 19 matching lines...) Expand all
400 scoped_ptr<extensions::ExternalProviderImpl> provider( 395 scoped_ptr<extensions::ExternalProviderImpl> provider(
401 new extensions::ExternalProviderImpl( 396 new extensions::ExternalProviderImpl(
402 &visitor, 397 &visitor,
403 loader, 398 loader,
404 profile.get(), 399 profile.get(),
405 extensions::Manifest::EXTERNAL_PREF, 400 extensions::Manifest::EXTERNAL_PREF,
406 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, 401 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD,
407 extensions::Extension::FROM_WEBSTORE | 402 extensions::Extension::FROM_WEBSTORE |
408 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); 403 extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
409 404
410 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) 405 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
411 .Times(0); 406 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
412 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
413 .Times(0);
414 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 407 EXPECT_CALL(visitor, OnExternalProviderReady(_))
415 .Times(1); 408 .Times(1);
409 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
416 410
417 // Manually request a load. 411 // Manually request a load.
418 loader->StartLoading(); 412 loader->StartLoading();
419 Mock::VerifyAndClearExpectations(&visitor); 413 Mock::VerifyAndClearExpectations(&visitor);
420 414
421 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) 415 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
422 .Times(0); 416 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(2);
423 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
424 .Times(2);
425 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 417 EXPECT_CALL(visitor, OnExternalProviderReady(_))
426 .Times(1); 418 .Times(1);
419 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
427 420
428 RunUntilIdle(); 421 RunUntilIdle();
429 EXPECT_TRUE(doc->IsReady()); 422 EXPECT_TRUE(doc->IsReady());
430 423
431 app_list::AppListSyncableService* service = 424 app_list::AppListSyncableService* service =
432 app_list::AppListSyncableServiceFactory::GetForProfile(profile.get()); 425 app_list::AppListSyncableServiceFactory::GetForProfile(profile.get());
433 ASSERT_TRUE(service); 426 ASSERT_TRUE(service);
434 EXPECT_EQ("EN OEM Name", service->GetOemFolderNameForTest()); 427 EXPECT_EQ("EN OEM Name", service->GetOemFolderNameForTest());
435 } 428 }
436 429
(...skipping 13 matching lines...) Expand all
450 scoped_ptr<extensions::ExternalProviderImpl> provider( 443 scoped_ptr<extensions::ExternalProviderImpl> provider(
451 new extensions::ExternalProviderImpl( 444 new extensions::ExternalProviderImpl(
452 &visitor, 445 &visitor,
453 loader, 446 loader,
454 profile.get(), 447 profile.get(),
455 extensions::Manifest::EXTERNAL_PREF, 448 extensions::Manifest::EXTERNAL_PREF,
456 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, 449 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD,
457 extensions::Extension::FROM_WEBSTORE | 450 extensions::Extension::FROM_WEBSTORE |
458 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); 451 extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
459 452
460 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) 453 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
461 .Times(0); 454 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
462 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
463 .Times(0);
464 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 455 EXPECT_CALL(visitor, OnExternalProviderReady(_))
465 .Times(1); 456 .Times(1);
457 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
466 458
467 // Manually request a load. 459 // Manually request a load.
468 loader->StartLoading(); 460 loader->StartLoading();
469 Mock::VerifyAndClearExpectations(&visitor); 461 Mock::VerifyAndClearExpectations(&visitor);
470 462
471 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) 463 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0);
472 .Times(0); 464 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0);
473 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
474 .Times(0);
475 EXPECT_CALL(visitor, OnExternalProviderReady(_)) 465 EXPECT_CALL(visitor, OnExternalProviderReady(_))
476 .Times(1); 466 .Times(1);
467 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0);
477 468
478 RunUntilIdle(); 469 RunUntilIdle();
479 EXPECT_TRUE(doc->IsReady()); 470 EXPECT_TRUE(doc->IsReady());
480 } 471 }
481 472
482 } // namespace chromeos 473 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698