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

Side by Side Diff: chrome/browser/extensions/external_provider_impl_chromeos_unittest.cc

Issue 644413003: Replace MockStatisticsProvider with FakeStatisticsProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add clarifying comments. Created 6 years, 2 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 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/app_mode/kiosk_app_manager.h" 12 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
13 #include "chrome/browser/chromeos/customization_document.h" 13 #include "chrome/browser/chromeos/customization_document.h"
14 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" 14 #include "chrome/browser/chromeos/login/users/fake_user_manager.h"
15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_service_test_base.h" 17 #include "chrome/browser/extensions/extension_service_test_base.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/test/base/testing_browser_process.h" 20 #include "chrome/test/base/testing_browser_process.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "chromeos/system/mock_statistics_provider.h" 22 #include "chromeos/system/fake_statistics_provider.h"
23 #include "chromeos/system/statistics_provider.h" 23 #include "chromeos/system/statistics_provider.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/test/test_utils.h" 25 #include "content/public/test/test_utils.h"
26 #include "testing/gmock/include/gmock/gmock.h"
27
28 using ::testing::_;
29 using ::testing::NotNull;
30 using ::testing::Return;
31 26
32 namespace extensions { 27 namespace extensions {
33 28
34 namespace { 29 namespace {
35 30
36 const char kExternalAppId[] = "kekdneafjmhmndejhmbcadfiiofngffo"; 31 const char kExternalAppId[] = "kekdneafjmhmndejhmbcadfiiofngffo";
37 32
38 class ExternalProviderImplChromeOSTest : public ExtensionServiceTestBase { 33 class ExternalProviderImplChromeOSTest : public ExtensionServiceTestBase {
39 public: 34 public:
40 ExternalProviderImplChromeOSTest() 35 ExternalProviderImplChromeOSTest()
(...skipping 21 matching lines...) Expand all
62 // ExtensionServiceTestBase overrides: 57 // ExtensionServiceTestBase overrides:
63 virtual void SetUp() override { 58 virtual void SetUp() override {
64 ExtensionServiceTestBase::SetUp(); 59 ExtensionServiceTestBase::SetUp();
65 60
66 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); 61 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_);
67 chromeos::ServicesCustomizationDocument::RegisterPrefs( 62 chromeos::ServicesCustomizationDocument::RegisterPrefs(
68 local_state_.registry()); 63 local_state_.registry());
69 64
70 external_externsions_overrides_.reset(new base::ScopedPathOverride( 65 external_externsions_overrides_.reset(new base::ScopedPathOverride(
71 chrome::DIR_EXTERNAL_EXTENSIONS, data_dir().Append("external"))); 66 chrome::DIR_EXTERNAL_EXTENSIONS, data_dir().Append("external")));
72
73 chromeos::system::StatisticsProvider::SetTestProvider(
74 &mock_statistics_provider_);
75 EXPECT_CALL(mock_statistics_provider_, GetMachineStatistic(_, NotNull()))
76 .WillRepeatedly(Return(false));
77 } 67 }
78 68
79 virtual void TearDown() override { 69 virtual void TearDown() override {
80 chromeos::KioskAppManager::Shutdown(); 70 chromeos::KioskAppManager::Shutdown();
81 chromeos::system::StatisticsProvider::SetTestProvider(NULL);
82 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); 71 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL);
83 } 72 }
84 73
85 private: 74 private:
86 TestingPrefServiceSimple local_state_; 75 TestingPrefServiceSimple local_state_;
87 scoped_ptr<base::ScopedPathOverride> external_externsions_overrides_; 76 scoped_ptr<base::ScopedPathOverride> external_externsions_overrides_;
88 chromeos::system::MockStatisticsProvider mock_statistics_provider_; 77 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_;
89 chromeos::FakeUserManager* fake_user_manager_; 78 chromeos::FakeUserManager* fake_user_manager_;
90 chromeos::ScopedUserManagerEnabler scoped_user_manager_; 79 chromeos::ScopedUserManagerEnabler scoped_user_manager_;
91 80
92 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplChromeOSTest); 81 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplChromeOSTest);
93 }; 82 };
94 83
95 } // namespace 84 } // namespace
96 85
97 // Normal mode, external app should be installed. 86 // Normal mode, external app should be installed.
98 TEST_F(ExternalProviderImplChromeOSTest, Normal) { 87 TEST_F(ExternalProviderImplChromeOSTest, Normal) {
(...skipping 15 matching lines...) Expand all
114 103
115 InitServiceWithExternalProviders(); 104 InitServiceWithExternalProviders();
116 105
117 service_->CheckForExternalUpdates(); 106 service_->CheckForExternalUpdates();
118 base::RunLoop().RunUntilIdle(); 107 base::RunLoop().RunUntilIdle();
119 108
120 EXPECT_FALSE(service_->GetInstalledExtension(kExternalAppId)); 109 EXPECT_FALSE(service_->GetInstalledExtension(kExternalAppId));
121 } 110 }
122 111
123 } // namespace extensions 112 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698