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

Side by Side Diff: chrome/browser/permissions/permission_uma_util_unittest.cc

Issue 2354613002: [Sync] Fix namespaces for the browser_sync component. (Closed)
Patch Set: Address comments. Created 4 years, 3 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
« no previous file with comments | « chrome/browser/permissions/permission_uma_util.cc ('k') | chrome/browser/profiles/profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/permissions/permission_uma_util.h" 5 #include "chrome/browser/permissions/permission_uma_util.h"
6 6
7 #include "base/test/scoped_command_line.h" 7 #include "base/test/scoped_command_line.h"
8 #include "chrome/browser/signin/fake_signin_manager_builder.h" 8 #include "chrome/browser/signin/fake_signin_manager_builder.h"
9 #include "chrome/browser/signin/signin_manager_factory.h" 9 #include "chrome/browser/signin/signin_manager_factory.h"
10 #include "chrome/browser/sync/profile_sync_service_factory.h" 10 #include "chrome/browser/sync/profile_sync_service_factory.h"
11 #include "chrome/browser/sync/profile_sync_test_util.h" 11 #include "chrome/browser/sync/profile_sync_test_util.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "components/browser_sync/browser_sync_switches.h" 15 #include "components/browser_sync/browser_sync_switches.h"
16 #include "components/browser_sync/profile_sync_service.h" 16 #include "components/browser_sync/profile_sync_service.h"
17 #include "components/browser_sync/profile_sync_service_mock.h" 17 #include "components/browser_sync/profile_sync_service_mock.h"
18 #include "components/prefs/pref_service.h" 18 #include "components/prefs/pref_service.h"
19 #include "components/sync/base/model_type.h" 19 #include "components/sync/base/model_type.h"
20 #include "components/sync/driver/glue/sync_backend_host_mock.h" 20 #include "components/sync/driver/glue/sync_backend_host_mock.h"
21 #include "components/sync/driver/sync_prefs.h" 21 #include "components/sync/driver/sync_prefs.h"
22 #include "content/public/test/test_browser_thread_bundle.h" 22 #include "content/public/test/test_browser_thread_bundle.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 using browser_sync::ProfileSyncServiceMock;
26
25 namespace { 27 namespace {
26 constexpr char kTestingGaiaId[] = "gaia_id"; 28 constexpr char kTestingGaiaId[] = "gaia_id";
27 constexpr char kTestingUsername[] = "fake_username"; 29 constexpr char kTestingUsername[] = "fake_username";
28 } // namespace 30 } // namespace
29 31
30 class PermissionUmaUtilTest : public testing::Test { 32 class PermissionUmaUtilTest : public testing::Test {
31 protected: 33 protected:
32 PermissionUmaUtilTest() {} 34 PermissionUmaUtilTest() {}
33 35
34 static bool IsOptedIntoPermissionActionReporting(Profile* profile) { 36 static bool IsOptedIntoPermissionActionReporting(Profile* profile) {
(...skipping 13 matching lines...) Expand all
48 SigninManagerFactory::GetForProfile(profile())); 50 SigninManagerFactory::GetForProfile(profile()));
49 signin_manager->SetAuthenticatedAccountInfo(kTestingGaiaId, 51 signin_manager->SetAuthenticatedAccountInfo(kTestingGaiaId,
50 kTestingUsername); 52 kTestingUsername);
51 } 53 }
52 54
53 void SetSafeBrowsing(bool enabled) { 55 void SetSafeBrowsing(bool enabled) {
54 PrefService* preferences = profile_->GetPrefs(); 56 PrefService* preferences = profile_->GetPrefs();
55 preferences->SetBoolean(prefs::kSafeBrowsingEnabled, enabled); 57 preferences->SetBoolean(prefs::kSafeBrowsingEnabled, enabled);
56 } 58 }
57 59
58 ProfileSyncService* GetProfileSyncService() { 60 browser_sync::ProfileSyncService* GetProfileSyncService() {
59 return ProfileSyncServiceFactory::GetForProfile(profile()); 61 return ProfileSyncServiceFactory::GetForProfile(profile());
60 } 62 }
61 63
62 ProfileSyncServiceMock* SetMockSyncService() { 64 ProfileSyncServiceMock* SetMockSyncService() {
63 ProfileSyncServiceMock* mock_sync_service = 65 ProfileSyncServiceMock* mock_sync_service =
64 static_cast<ProfileSyncServiceMock*>( 66 static_cast<ProfileSyncServiceMock*>(
65 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 67 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
66 profile(), BuildMockProfileSyncService)); 68 profile(), BuildMockProfileSyncService));
67 EXPECT_CALL(*mock_sync_service, CanSyncStart()) 69 EXPECT_CALL(*mock_sync_service, CanSyncStart())
68 .WillRepeatedly(testing::Return(true)); 70 .WillRepeatedly(testing::Return(true));
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 IsOptedIntoPermissionActionReportingSyncPassphraseCheck) { 205 IsOptedIntoPermissionActionReportingSyncPassphraseCheck) {
204 SetSafeBrowsing(true); 206 SetSafeBrowsing(true);
205 FakeSignIn(); 207 FakeSignIn();
206 ProfileSyncServiceMock* mock_sync_service = SetMockSyncService(); 208 ProfileSyncServiceMock* mock_sync_service = SetMockSyncService();
207 EXPECT_TRUE(IsOptedIntoPermissionActionReporting(profile())); 209 EXPECT_TRUE(IsOptedIntoPermissionActionReporting(profile()));
208 210
209 EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) 211 EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase())
210 .WillOnce(testing::Return(true)); 212 .WillOnce(testing::Return(true));
211 EXPECT_FALSE(IsOptedIntoPermissionActionReporting(profile())); 213 EXPECT_FALSE(IsOptedIntoPermissionActionReporting(profile()));
212 } 214 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_uma_util.cc ('k') | chrome/browser/profiles/profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698