| OLD | NEW |
| 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" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | 13 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
| 14 #include "chrome/browser/extensions/external_provider_impl.h" | 14 #include "chrome/browser/extensions/external_provider_impl.h" |
| 15 #include "chrome/browser/prefs/browser_prefs.h" | 15 #include "chrome/browser/prefs/browser_prefs.h" |
| 16 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 16 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 17 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 17 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 20 #include "chromeos/dbus/dbus_thread_manager.h" | 20 #include "chromeos/dbus/dbus_thread_manager.h" |
| 21 #include "chromeos/network/network_handler.h" | 21 #include "chromeos/network/network_handler.h" |
| 22 #include "chromeos/network/network_state.h" | 22 #include "chromeos/network/network_state.h" |
| 23 #include "chromeos/network/network_state_handler.h" | 23 #include "chromeos/network/network_state_handler.h" |
| 24 #include "chromeos/system/fake_statistics_provider.h" | 24 #include "chromeos/system/fake_statistics_provider.h" |
| 25 #include "components/pref_registry/pref_registry_syncable.h" | 25 #include "components/pref_registry/pref_registry_syncable.h" |
| 26 #include "components/syncable_prefs/pref_service_mock_factory.h" | 26 #include "components/syncable_prefs/pref_service_mock_factory.h" |
| 27 #include "components/syncable_prefs/pref_service_syncable.h" | 27 #include "components/syncable_prefs/pref_service_syncable.h" |
| 28 #include "content/public/test/test_browser_thread_bundle.h" | 28 #include "content/public/test/test_browser_thread_bundle.h" |
| 29 #include "extensions/browser/external_install_info.h" |
| 29 #include "extensions/common/extension.h" | 30 #include "extensions/common/extension.h" |
| 30 #include "extensions/common/manifest.h" | 31 #include "extensions/common/manifest.h" |
| 31 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
| 32 #include "net/http/http_status_code.h" | 33 #include "net/http/http_status_code.h" |
| 33 #include "net/url_request/test_url_fetcher_factory.h" | 34 #include "net/url_request/test_url_fetcher_factory.h" |
| 34 #include "net/url_request/url_request_status.h" | 35 #include "net/url_request/url_request_status.h" |
| 35 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 37 | 38 |
| 38 using ::testing::Exactly; | 39 using ::testing::Exactly; |
| 39 using ::testing::Invoke; | 40 using ::testing::Invoke; |
| 40 using ::testing::Mock; | 41 using ::testing::Mock; |
| 41 using ::testing::_; | 42 using ::testing::_; |
| 43 using extensions::ExternalInstallInfoFile; |
| 44 using extensions::ExternalInstallInfoUpdateUrl; |
| 42 | 45 |
| 43 namespace { | 46 namespace { |
| 44 | 47 |
| 45 const char kGoodStartupManifest[] = | 48 const char kGoodStartupManifest[] = |
| 46 "{" | 49 "{" |
| 47 " \"version\": \"1.0\"," | 50 " \"version\": \"1.0\"," |
| 48 " \"initial_locale\" : \"en-US\"," | 51 " \"initial_locale\" : \"en-US\"," |
| 49 " \"initial_timezone\" : \"US/Pacific\"," | 52 " \"initial_timezone\" : \"US/Pacific\"," |
| 50 " \"keyboard_layout\" : \"xkb:us::eng\"," | 53 " \"keyboard_layout\" : \"xkb:us::eng\"," |
| 51 " \"setup_content\" : {" | 54 " \"setup_content\" : {" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 new net::HttpResponseHeaders(""); | 180 new net::HttpResponseHeaders(""); |
| 178 download_headers->AddHeader("Content-Type: application/json"); | 181 download_headers->AddHeader("Content-Type: application/json"); |
| 179 fetcher->set_response_headers(download_headers); | 182 fetcher->set_response_headers(download_headers); |
| 180 } | 183 } |
| 181 | 184 |
| 182 class MockExternalProviderVisitor | 185 class MockExternalProviderVisitor |
| 183 : public extensions::ExternalProviderInterface::VisitorInterface { | 186 : public extensions::ExternalProviderInterface::VisitorInterface { |
| 184 public: | 187 public: |
| 185 MockExternalProviderVisitor() {} | 188 MockExternalProviderVisitor() {} |
| 186 | 189 |
| 187 MOCK_METHOD7(OnExternalExtensionFileFound, | 190 MOCK_METHOD1(OnExternalExtensionFileFound, |
| 188 bool(const std::string&, | 191 bool(const ExternalInstallInfoFile&)); |
| 189 const base::Version*, | 192 MOCK_METHOD2(OnExternalExtensionUpdateUrlFound, |
| 190 const base::FilePath&, | 193 bool(const ExternalInstallInfoUpdateUrl&, 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, | 194 MOCK_METHOD1(OnExternalProviderReady, |
| 203 void(const extensions::ExternalProviderInterface* provider)); | 195 void(const extensions::ExternalProviderInterface* provider)); |
| 196 MOCK_METHOD4(OnExternalProviderUpdateComplete, |
| 197 void(const extensions::ExternalProviderInterface*, |
| 198 const ScopedVector<ExternalInstallInfoUpdateUrl>&, |
| 199 const ScopedVector<ExternalInstallInfoFile>&, |
| 200 const std::set<std::string>& removed_extensions)); |
| 204 }; | 201 }; |
| 205 | 202 |
| 206 class ServicesCustomizationDocumentTest : public testing::Test { | 203 class ServicesCustomizationDocumentTest : public testing::Test { |
| 207 protected: | 204 protected: |
| 208 ServicesCustomizationDocumentTest() | 205 ServicesCustomizationDocumentTest() |
| 209 : factory_(nullptr, | 206 : factory_(nullptr, |
| 210 base::Bind(&TestURLFetcherCallback::CreateURLFetcher, | 207 base::Bind(&TestURLFetcherCallback::CreateURLFetcher, |
| 211 base::Unretained(&url_callback_))) {} | 208 base::Unretained(&url_callback_))) {} |
| 212 | 209 |
| 213 // testing::Test: | 210 // testing::Test: |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 scoped_ptr<extensions::ExternalProviderImpl> provider( | 352 scoped_ptr<extensions::ExternalProviderImpl> provider( |
| 356 new extensions::ExternalProviderImpl( | 353 new extensions::ExternalProviderImpl( |
| 357 &visitor, | 354 &visitor, |
| 358 loader, | 355 loader, |
| 359 profile.get(), | 356 profile.get(), |
| 360 extensions::Manifest::EXTERNAL_PREF, | 357 extensions::Manifest::EXTERNAL_PREF, |
| 361 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, | 358 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 362 extensions::Extension::FROM_WEBSTORE | | 359 extensions::Extension::FROM_WEBSTORE | |
| 363 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); | 360 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); |
| 364 | 361 |
| 365 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) | 362 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); |
| 366 .Times(0); | 363 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); |
| 367 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) | |
| 368 .Times(0); | |
| 369 EXPECT_CALL(visitor, OnExternalProviderReady(_)) | 364 EXPECT_CALL(visitor, OnExternalProviderReady(_)) |
| 370 .Times(1); | 365 .Times(1); |
| 366 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); |
| 371 | 367 |
| 372 // Manually request a load. | 368 // Manually request a load. |
| 373 RunUntilIdle(); | 369 RunUntilIdle(); |
| 374 loader->StartLoading(); | 370 loader->StartLoading(); |
| 375 Mock::VerifyAndClearExpectations(&visitor); | 371 Mock::VerifyAndClearExpectations(&visitor); |
| 376 | 372 |
| 377 RunUntilIdle(); | 373 RunUntilIdle(); |
| 378 // Empty customization is used when there is no customization ID in VPD. | 374 // Empty customization is used when there is no customization ID in VPD. |
| 379 EXPECT_TRUE(doc->IsReady()); | 375 EXPECT_TRUE(doc->IsReady()); |
| 380 } | 376 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 400 scoped_ptr<extensions::ExternalProviderImpl> provider( | 396 scoped_ptr<extensions::ExternalProviderImpl> provider( |
| 401 new extensions::ExternalProviderImpl( | 397 new extensions::ExternalProviderImpl( |
| 402 &visitor, | 398 &visitor, |
| 403 loader, | 399 loader, |
| 404 profile.get(), | 400 profile.get(), |
| 405 extensions::Manifest::EXTERNAL_PREF, | 401 extensions::Manifest::EXTERNAL_PREF, |
| 406 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, | 402 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 407 extensions::Extension::FROM_WEBSTORE | | 403 extensions::Extension::FROM_WEBSTORE | |
| 408 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); | 404 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); |
| 409 | 405 |
| 410 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) | 406 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); |
| 411 .Times(0); | 407 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); |
| 412 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) | |
| 413 .Times(0); | |
| 414 EXPECT_CALL(visitor, OnExternalProviderReady(_)) | 408 EXPECT_CALL(visitor, OnExternalProviderReady(_)) |
| 415 .Times(1); | 409 .Times(1); |
| 410 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); |
| 416 | 411 |
| 417 // Manually request a load. | 412 // Manually request a load. |
| 418 loader->StartLoading(); | 413 loader->StartLoading(); |
| 419 Mock::VerifyAndClearExpectations(&visitor); | 414 Mock::VerifyAndClearExpectations(&visitor); |
| 420 | 415 |
| 421 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) | 416 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); |
| 422 .Times(0); | 417 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(2); |
| 423 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) | |
| 424 .Times(2); | |
| 425 EXPECT_CALL(visitor, OnExternalProviderReady(_)) | 418 EXPECT_CALL(visitor, OnExternalProviderReady(_)) |
| 426 .Times(1); | 419 .Times(1); |
| 420 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); |
| 427 | 421 |
| 428 RunUntilIdle(); | 422 RunUntilIdle(); |
| 429 EXPECT_TRUE(doc->IsReady()); | 423 EXPECT_TRUE(doc->IsReady()); |
| 430 | 424 |
| 431 app_list::AppListSyncableService* service = | 425 app_list::AppListSyncableService* service = |
| 432 app_list::AppListSyncableServiceFactory::GetForProfile(profile.get()); | 426 app_list::AppListSyncableServiceFactory::GetForProfile(profile.get()); |
| 433 ASSERT_TRUE(service); | 427 ASSERT_TRUE(service); |
| 434 EXPECT_EQ("EN OEM Name", service->GetOemFolderNameForTest()); | 428 EXPECT_EQ("EN OEM Name", service->GetOemFolderNameForTest()); |
| 435 } | 429 } |
| 436 | 430 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 450 scoped_ptr<extensions::ExternalProviderImpl> provider( | 444 scoped_ptr<extensions::ExternalProviderImpl> provider( |
| 451 new extensions::ExternalProviderImpl( | 445 new extensions::ExternalProviderImpl( |
| 452 &visitor, | 446 &visitor, |
| 453 loader, | 447 loader, |
| 454 profile.get(), | 448 profile.get(), |
| 455 extensions::Manifest::EXTERNAL_PREF, | 449 extensions::Manifest::EXTERNAL_PREF, |
| 456 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, | 450 extensions::Manifest::EXTERNAL_PREF_DOWNLOAD, |
| 457 extensions::Extension::FROM_WEBSTORE | | 451 extensions::Extension::FROM_WEBSTORE | |
| 458 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); | 452 extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); |
| 459 | 453 |
| 460 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) | 454 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); |
| 461 .Times(0); | 455 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); |
| 462 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) | |
| 463 .Times(0); | |
| 464 EXPECT_CALL(visitor, OnExternalProviderReady(_)) | 456 EXPECT_CALL(visitor, OnExternalProviderReady(_)) |
| 465 .Times(1); | 457 .Times(1); |
| 458 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); |
| 466 | 459 |
| 467 // Manually request a load. | 460 // Manually request a load. |
| 468 loader->StartLoading(); | 461 loader->StartLoading(); |
| 469 Mock::VerifyAndClearExpectations(&visitor); | 462 Mock::VerifyAndClearExpectations(&visitor); |
| 470 | 463 |
| 471 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _)) | 464 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_)).Times(0); |
| 472 .Times(0); | 465 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _)).Times(0); |
| 473 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) | |
| 474 .Times(0); | |
| 475 EXPECT_CALL(visitor, OnExternalProviderReady(_)) | 466 EXPECT_CALL(visitor, OnExternalProviderReady(_)) |
| 476 .Times(1); | 467 .Times(1); |
| 468 EXPECT_CALL(visitor, OnExternalProviderUpdateComplete(_, _, _, _)).Times(0); |
| 477 | 469 |
| 478 RunUntilIdle(); | 470 RunUntilIdle(); |
| 479 EXPECT_TRUE(doc->IsReady()); | 471 EXPECT_TRUE(doc->IsReady()); |
| 480 } | 472 } |
| 481 | 473 |
| 482 } // namespace chromeos | 474 } // namespace chromeos |
| OLD | NEW |