| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/external_provider_impl.h" | 5 #include "chrome/browser/extensions/external_provider_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
| 10 #include "base/test/scoped_path_override.h" | 10 #include "base/test/scoped_path_override.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/chromeos/customization_document.h" | 12 #include "chrome/browser/chromeos/customization_document.h" |
| 13 #include "chrome/browser/chromeos/login/fake_user_manager.h" |
| 13 #include "chrome/browser/extensions/extension_service_unittest.h" | 14 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 14 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
| 17 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 18 #include "chromeos/system/mock_statistics_provider.h" | 19 #include "chromeos/system/mock_statistics_provider.h" |
| 19 #include "chromeos/system/statistics_provider.h" | 20 #include "chromeos/system/statistics_provider.h" |
| 20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 23 | 24 |
| 24 using ::testing::_; | 25 using ::testing::_; |
| 25 using ::testing::NotNull; | 26 using ::testing::NotNull; |
| 26 using ::testing::Return; | 27 using ::testing::Return; |
| 27 | 28 |
| 28 namespace extensions { | 29 namespace extensions { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const char kExternalAppId[] = "kekdneafjmhmndejhmbcadfiiofngffo"; | 33 const char kExternalAppId[] = "kekdneafjmhmndejhmbcadfiiofngffo"; |
| 33 | 34 |
| 34 class ExternalProviderImplChromeOSTest : public ExtensionServiceTestBase { | 35 class ExternalProviderImplChromeOSTest : public ExtensionServiceTestBase { |
| 35 public: | 36 public: |
| 36 ExternalProviderImplChromeOSTest() {} | 37 ExternalProviderImplChromeOSTest() |
| 38 : fake_user_manager_(new chromeos::FakeUserManager()), |
| 39 scoped_user_manager_(fake_user_manager_) { |
| 40 } |
| 41 |
| 37 virtual ~ExternalProviderImplChromeOSTest() {} | 42 virtual ~ExternalProviderImplChromeOSTest() {} |
| 38 | 43 |
| 39 void InitServiceWithExternalProviders() { | 44 void InitServiceWithExternalProviders() { |
| 40 InitializeEmptyExtensionService(); | 45 InitializeEmptyExtensionService(); |
| 41 service_->Init(); | 46 service_->Init(); |
| 42 | 47 |
| 43 ProviderCollection providers; | 48 ProviderCollection providers; |
| 44 extensions::ExternalProviderImpl::CreateExternalProviders( | 49 extensions::ExternalProviderImpl::CreateExternalProviders( |
| 45 service_, profile_.get(), &providers); | 50 service_, profile_.get(), &providers); |
| 46 | 51 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 | 76 |
| 72 virtual void TearDown() OVERRIDE { | 77 virtual void TearDown() OVERRIDE { |
| 73 chromeos::system::StatisticsProvider::SetTestProvider(NULL); | 78 chromeos::system::StatisticsProvider::SetTestProvider(NULL); |
| 74 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); | 79 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); |
| 75 } | 80 } |
| 76 | 81 |
| 77 private: | 82 private: |
| 78 TestingPrefServiceSimple local_state_; | 83 TestingPrefServiceSimple local_state_; |
| 79 scoped_ptr<base::ScopedPathOverride> external_externsions_overrides_; | 84 scoped_ptr<base::ScopedPathOverride> external_externsions_overrides_; |
| 80 chromeos::system::MockStatisticsProvider mock_statistics_provider_; | 85 chromeos::system::MockStatisticsProvider mock_statistics_provider_; |
| 86 chromeos::FakeUserManager* fake_user_manager_; |
| 87 chromeos::ScopedUserManagerEnabler scoped_user_manager_; |
| 81 | 88 |
| 82 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplChromeOSTest); | 89 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplChromeOSTest); |
| 83 }; | 90 }; |
| 84 | 91 |
| 85 } // namespace | 92 } // namespace |
| 86 | 93 |
| 87 // Normal mode, external app should be installed. | 94 // Normal mode, external app should be installed. |
| 88 TEST_F(ExternalProviderImplChromeOSTest, Normal) { | 95 TEST_F(ExternalProviderImplChromeOSTest, Normal) { |
| 89 InitServiceWithExternalProviders(); | 96 InitServiceWithExternalProviders(); |
| 90 | 97 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 104 | 111 |
| 105 InitServiceWithExternalProviders(); | 112 InitServiceWithExternalProviders(); |
| 106 | 113 |
| 107 service_->CheckForExternalUpdates(); | 114 service_->CheckForExternalUpdates(); |
| 108 base::RunLoop().RunUntilIdle(); | 115 base::RunLoop().RunUntilIdle(); |
| 109 | 116 |
| 110 EXPECT_FALSE(service_->GetInstalledExtension(kExternalAppId)); | 117 EXPECT_FALSE(service_->GetInstalledExtension(kExternalAppId)); |
| 111 } | 118 } |
| 112 | 119 |
| 113 } // namespace extensions | 120 } // namespace extensions |
| OLD | NEW |