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

Side by Side Diff: components/sync_driver/device_info_data_type_controller_unittest.cc

Issue 780713002: Fix remaining WeakPtrFactory ordering problems (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "components/sync_driver/device_info_data_type_controller.h" 10 #include "components/sync_driver/device_info_data_type_controller.h"
11 #include "components/sync_driver/local_device_info_provider_mock.h" 11 #include "components/sync_driver/local_device_info_provider_mock.h"
12 #include "components/sync_driver/sync_api_component_factory.h" 12 #include "components/sync_driver/sync_api_component_factory.h"
13 #include "sync/internal_api/public/base/model_type.h" 13 #include "sync/internal_api/public/base/model_type.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace sync_driver { 16 namespace sync_driver {
17 17
18 namespace { 18 namespace {
19 19
20 class DeviceInfoDataTypeControllerTest : public testing::Test, 20 class DeviceInfoDataTypeControllerTest : public testing::Test,
21 public SyncApiComponentFactory { 21 public SyncApiComponentFactory {
22 public: 22 public:
23 DeviceInfoDataTypeControllerTest() 23 DeviceInfoDataTypeControllerTest()
24 : load_finished_(false), 24 : load_finished_(false),
25 weak_ptr_factory_(this), 25 last_type_(syncer::UNSPECIFIED),
26 last_type_(syncer::UNSPECIFIED) {} 26 weak_ptr_factory_(this) {}
27 ~DeviceInfoDataTypeControllerTest() override {} 27 ~DeviceInfoDataTypeControllerTest() override {}
28 28
29 void SetUp() override { 29 void SetUp() override {
30 local_device_.reset(new LocalDeviceInfoProviderMock( 30 local_device_.reset(new LocalDeviceInfoProviderMock(
31 "cache_guid", 31 "cache_guid",
32 "Wayne Gretzky's Hacking Box", 32 "Wayne Gretzky's Hacking Box",
33 "Chromium 10k", 33 "Chromium 10k",
34 "Chrome 10k", 34 "Chrome 10k",
35 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, 35 sync_pb::SyncEnums_DeviceType_TYPE_LINUX,
36 "device_id")); 36 "device_id"));
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return testing::AssertionSuccess(); 101 return testing::AssertionSuccess();
102 } 102 }
103 103
104 protected: 104 protected:
105 scoped_refptr<DeviceInfoDataTypeController> controller_; 105 scoped_refptr<DeviceInfoDataTypeController> controller_;
106 scoped_ptr<LocalDeviceInfoProviderMock> local_device_; 106 scoped_ptr<LocalDeviceInfoProviderMock> local_device_;
107 bool load_finished_; 107 bool load_finished_;
108 108
109 private: 109 private:
110 base::MessageLoopForUI message_loop_; 110 base::MessageLoopForUI message_loop_;
111 base::WeakPtrFactory<DeviceInfoDataTypeControllerTest> weak_ptr_factory_;
112 syncer::ModelType last_type_; 111 syncer::ModelType last_type_;
113 syncer::SyncError last_error_; 112 syncer::SyncError last_error_;
113 base::WeakPtrFactory<DeviceInfoDataTypeControllerTest> weak_ptr_factory_;
114 }; 114 };
115 115
116 TEST_F(DeviceInfoDataTypeControllerTest, StartModels) { 116 TEST_F(DeviceInfoDataTypeControllerTest, StartModels) {
117 Start(); 117 Start();
118 EXPECT_EQ(DataTypeController::MODEL_LOADED, controller_->state()); 118 EXPECT_EQ(DataTypeController::MODEL_LOADED, controller_->state());
119 EXPECT_TRUE(LoadResult()); 119 EXPECT_TRUE(LoadResult());
120 } 120 }
121 121
122 TEST_F(DeviceInfoDataTypeControllerTest, StartModelsDelayedByLocalDevice) { 122 TEST_F(DeviceInfoDataTypeControllerTest, StartModelsDelayedByLocalDevice) {
123 local_device_->SetInitialized(false); 123 local_device_->SetInitialized(false);
(...skipping 15 matching lines...) Expand all
139 controller_->Stop(); 139 controller_->Stop();
140 // Destroy |local_device_| and |controller_| out of order 140 // Destroy |local_device_| and |controller_| out of order
141 // to verify that the controller doesn't crash in the destructor. 141 // to verify that the controller doesn't crash in the destructor.
142 local_device_.reset(); 142 local_device_.reset();
143 controller_ = NULL; 143 controller_ = NULL;
144 } 144 }
145 145
146 } // namespace 146 } // namespace
147 147
148 } // namespace sync_driver 148 } // namespace sync_driver
OLDNEW
« no previous file with comments | « components/suggestions/image_manager.h ('k') | content/browser/download/download_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698