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

Side by Side Diff: chrome/browser/sync/sync_startup_tracker_unittest.cc

Issue 2422253002: [Sync] Rewriting ".reset(new" pattern to use "= base::MakeUnique" instead. (Closed)
Patch Set: Fixing compile. Created 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/sync/sync_startup_tracker.h" 5 #include "chrome/browser/sync/sync_startup_tracker.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/sync/profile_sync_service_factory.h" 10 #include "chrome/browser/sync/profile_sync_service_factory.h"
10 #include "chrome/browser/sync/profile_sync_test_util.h" 11 #include "chrome/browser/sync/profile_sync_test_util.h"
11 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 13 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 using ::testing::_; 17 using ::testing::_;
17 using ::testing::AnyNumber; 18 using ::testing::AnyNumber;
18 using ::testing::Mock; 19 using ::testing::Mock;
19 using ::testing::Return; 20 using ::testing::Return;
20 using ::testing::ReturnRef; 21 using ::testing::ReturnRef;
21 22
22 namespace { 23 namespace {
23 24
24 class MockObserver : public SyncStartupTracker::Observer { 25 class MockObserver : public SyncStartupTracker::Observer {
25 public: 26 public:
26 MOCK_METHOD0(SyncStartupCompleted, void(void)); 27 MOCK_METHOD0(SyncStartupCompleted, void(void));
27 MOCK_METHOD0(SyncStartupFailed, void(void)); 28 MOCK_METHOD0(SyncStartupFailed, void(void));
28 }; 29 };
29 30
30 class SyncStartupTrackerTest : public testing::Test { 31 class SyncStartupTrackerTest : public testing::Test {
31 public: 32 public:
32 SyncStartupTrackerTest() : 33 SyncStartupTrackerTest() :
33 no_error_(GoogleServiceAuthError::NONE) { 34 no_error_(GoogleServiceAuthError::NONE) {
34 } 35 }
35 void SetUp() override { 36 void SetUp() override {
36 profile_.reset(new TestingProfile()); 37 profile_ = base::MakeUnique<TestingProfile>();
37 mock_pss_ = static_cast<browser_sync::ProfileSyncServiceMock*>( 38 mock_pss_ = static_cast<browser_sync::ProfileSyncServiceMock*>(
38 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 39 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
39 profile_.get(), BuildMockProfileSyncService)); 40 profile_.get(), BuildMockProfileSyncService));
40 41
41 // Make gmock not spam the output with information about these uninteresting 42 // Make gmock not spam the output with information about these uninteresting
42 // calls. 43 // calls.
43 EXPECT_CALL(*mock_pss_, AddObserver(_)).Times(AnyNumber()); 44 EXPECT_CALL(*mock_pss_, AddObserver(_)).Times(AnyNumber());
44 EXPECT_CALL(*mock_pss_, RemoveObserver(_)).Times(AnyNumber()); 45 EXPECT_CALL(*mock_pss_, RemoveObserver(_)).Times(AnyNumber());
45 EXPECT_CALL(*mock_pss_, GetAuthError()). 46 EXPECT_CALL(*mock_pss_, GetAuthError()).
46 WillRepeatedly(ReturnRef(no_error_)); 47 WillRepeatedly(ReturnRef(no_error_));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false)); 142 EXPECT_CALL(*mock_pss_, IsBackendInitialized()).WillRepeatedly(Return(false));
142 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true)); 143 EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
143 GoogleServiceAuthError error( 144 GoogleServiceAuthError error(
144 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); 145 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
145 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); 146 EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error));
146 EXPECT_CALL(observer_, SyncStartupFailed()); 147 EXPECT_CALL(observer_, SyncStartupFailed());
147 tracker.OnStateChanged(); 148 tracker.OnStateChanged();
148 } 149 }
149 150
150 } // namespace 151 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698