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/test/scoped_path_override.h" | 10 #include "base/test/scoped_path_override.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/chromeos/customization_document.h" |
11 #include "chrome/browser/extensions/extension_service_unittest.h" | 13 #include "chrome/browser/extensions/extension_service_unittest.h" |
12 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
13 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/test/base/testing_browser_process.h" |
14 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
15 #include "chromeos/system/mock_statistics_provider.h" | 18 #include "chromeos/system/mock_statistics_provider.h" |
16 #include "chromeos/system/statistics_provider.h" | 19 #include "chromeos/system/statistics_provider.h" |
17 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
18 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
20 | 23 |
21 using ::testing::_; | 24 using ::testing::_; |
22 using ::testing::NotNull; | 25 using ::testing::NotNull; |
23 using ::testing::Return; | 26 using ::testing::Return; |
(...skipping 21 matching lines...) Expand all Loading... |
45 i != providers.end(); | 48 i != providers.end(); |
46 ++i) { | 49 ++i) { |
47 service_->AddProviderForTesting(i->release()); | 50 service_->AddProviderForTesting(i->release()); |
48 } | 51 } |
49 } | 52 } |
50 | 53 |
51 // ExtensionServiceTestBase overrides: | 54 // ExtensionServiceTestBase overrides: |
52 virtual void SetUp() OVERRIDE { | 55 virtual void SetUp() OVERRIDE { |
53 ExtensionServiceTestBase::SetUp(); | 56 ExtensionServiceTestBase::SetUp(); |
54 | 57 |
| 58 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); |
| 59 chromeos::ServicesCustomizationDocument::RegisterPrefs( |
| 60 local_state_.registry()); |
| 61 |
55 external_externsions_overrides_.reset( | 62 external_externsions_overrides_.reset( |
56 new base::ScopedPathOverride(chrome::DIR_EXTERNAL_EXTENSIONS, | 63 new base::ScopedPathOverride(chrome::DIR_EXTERNAL_EXTENSIONS, |
57 data_dir_.Append("external"))); | 64 data_dir_.Append("external"))); |
58 | 65 |
59 chromeos::system::StatisticsProvider::SetTestProvider( | 66 chromeos::system::StatisticsProvider::SetTestProvider( |
60 &mock_statistics_provider_); | 67 &mock_statistics_provider_); |
61 EXPECT_CALL(mock_statistics_provider_, GetMachineStatistic(_, NotNull())) | 68 EXPECT_CALL(mock_statistics_provider_, GetMachineStatistic(_, NotNull())) |
62 .WillRepeatedly(Return(false)); | 69 .WillRepeatedly(Return(false)); |
63 } | 70 } |
64 | 71 |
65 virtual void TearDown() OVERRIDE { | 72 virtual void TearDown() OVERRIDE { |
66 chromeos::system::StatisticsProvider::SetTestProvider(NULL); | 73 chromeos::system::StatisticsProvider::SetTestProvider(NULL); |
| 74 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); |
67 } | 75 } |
68 | 76 |
69 private: | 77 private: |
| 78 TestingPrefServiceSimple local_state_; |
70 scoped_ptr<base::ScopedPathOverride> external_externsions_overrides_; | 79 scoped_ptr<base::ScopedPathOverride> external_externsions_overrides_; |
71 chromeos::system::MockStatisticsProvider mock_statistics_provider_; | 80 chromeos::system::MockStatisticsProvider mock_statistics_provider_; |
72 | 81 |
73 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplChromeOSTest); | 82 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplChromeOSTest); |
74 }; | 83 }; |
75 | 84 |
76 } // namespace | 85 } // namespace |
77 | 86 |
78 // Normal mode, external app should be installed. | 87 // Normal mode, external app should be installed. |
79 TEST_F(ExternalProviderImplChromeOSTest, Normal) { | 88 TEST_F(ExternalProviderImplChromeOSTest, Normal) { |
(...skipping 15 matching lines...) Expand all Loading... |
95 | 104 |
96 InitServiceWithExternalProviders(); | 105 InitServiceWithExternalProviders(); |
97 | 106 |
98 service_->CheckForExternalUpdates(); | 107 service_->CheckForExternalUpdates(); |
99 base::RunLoop().RunUntilIdle(); | 108 base::RunLoop().RunUntilIdle(); |
100 | 109 |
101 EXPECT_FALSE(service_->GetInstalledExtension(kExternalAppId)); | 110 EXPECT_FALSE(service_->GetInstalledExtension(kExternalAppId)); |
102 } | 111 } |
103 | 112 |
104 } // namespace extensions | 113 } // namespace extensions |
OLD | NEW |