OLD | NEW |
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 "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace sync_driver { | 15 namespace sync_driver { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 class DeviceInfoDataTypeControllerTest : public testing::Test, | 19 class DeviceInfoDataTypeControllerTest : public testing::Test, |
20 public SyncApiComponentFactory { | 20 public SyncApiComponentFactory { |
21 public: | 21 public: |
22 DeviceInfoDataTypeControllerTest() | 22 DeviceInfoDataTypeControllerTest() |
23 : load_finished_(false), | 23 : load_finished_(false), |
24 weak_ptr_factory_(this), | 24 weak_ptr_factory_(this), |
25 last_type_(syncer::UNSPECIFIED) {} | 25 last_type_(syncer::UNSPECIFIED) {} |
26 virtual ~DeviceInfoDataTypeControllerTest() {} | 26 ~DeviceInfoDataTypeControllerTest() override {} |
27 | 27 |
28 virtual void SetUp() override { | 28 void SetUp() override { |
29 local_device_.reset(new LocalDeviceInfoProviderMock( | 29 local_device_.reset(new LocalDeviceInfoProviderMock( |
30 "cache_guid", | 30 "cache_guid", |
31 "Wayne Gretzky's Hacking Box", | 31 "Wayne Gretzky's Hacking Box", |
32 "Chromium 10k", | 32 "Chromium 10k", |
33 "Chrome 10k", | 33 "Chrome 10k", |
34 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, | 34 sync_pb::SyncEnums_DeviceType_TYPE_LINUX, |
35 "device_id")); | 35 "device_id")); |
36 | 36 |
37 controller_ = new DeviceInfoDataTypeController( | 37 controller_ = new DeviceInfoDataTypeController( |
38 base::MessageLoopProxy::current(), | 38 base::MessageLoopProxy::current(), |
39 base::Closure(), | 39 base::Closure(), |
40 this, | 40 this, |
41 local_device_.get()); | 41 local_device_.get()); |
42 | 42 |
43 load_finished_ = false; | 43 load_finished_ = false; |
44 last_type_ = syncer::UNSPECIFIED; | 44 last_type_ = syncer::UNSPECIFIED; |
45 last_error_ = syncer::SyncError(); | 45 last_error_ = syncer::SyncError(); |
46 } | 46 } |
47 | 47 |
48 virtual void TearDown() override { | 48 void TearDown() override { |
49 controller_ = NULL; | 49 controller_ = NULL; |
50 local_device_.reset(); | 50 local_device_.reset(); |
51 } | 51 } |
52 | 52 |
53 void Start() { | 53 void Start() { |
54 controller_->LoadModels( | 54 controller_->LoadModels( |
55 base::Bind(&DeviceInfoDataTypeControllerTest::OnLoadFinished, | 55 base::Bind(&DeviceInfoDataTypeControllerTest::OnLoadFinished, |
56 weak_ptr_factory_.GetWeakPtr())); | 56 weak_ptr_factory_.GetWeakPtr())); |
57 } | 57 } |
58 | 58 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 controller_->Stop(); | 136 controller_->Stop(); |
137 // Destroy |local_device_| and |controller_| out of order | 137 // Destroy |local_device_| and |controller_| out of order |
138 // to verify that the controller doesn't crash in the destructor. | 138 // to verify that the controller doesn't crash in the destructor. |
139 local_device_.reset(); | 139 local_device_.reset(); |
140 controller_ = NULL; | 140 controller_ = NULL; |
141 } | 141 } |
142 | 142 |
143 } // namespace | 143 } // namespace |
144 | 144 |
145 } // namespace sync_driver | 145 } // namespace sync_driver |
OLD | NEW |