OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/guid.h" | 9 #include "base/guid.h" |
10 #include "base/message_loop/message_loop.h" | |
11 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/thread_task_runner_handle.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" | 13 #include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.
h" |
14 #include "chrome/browser/extensions/extension_api_unittest.h" | 14 #include "chrome/browser/extensions/extension_api_unittest.h" |
15 #include "chrome/browser/extensions/test_extension_prefs.h" | 15 #include "chrome/browser/extensions/test_extension_prefs.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
18 #include "chrome/browser/sync/profile_sync_service_mock.h" | 18 #include "chrome/browser/sync/profile_sync_service_mock.h" |
19 #include "components/sync_driver/device_info.h" | 19 #include "components/sync_driver/device_info.h" |
| 20 #include "content/public/test/test_browser_thread_bundle.h" |
20 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 using sync_driver::DeviceInfo; | 25 using sync_driver::DeviceInfo; |
25 using sync_driver::DeviceInfoTracker; | 26 using sync_driver::DeviceInfoTracker; |
26 using testing::Return; | 27 using testing::Return; |
27 | 28 |
28 namespace extensions { | 29 namespace extensions { |
29 | 30 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 void RemoveObserver(Observer* observer) override { NOTREACHED(); } | 66 void RemoveObserver(Observer* observer) override { NOTREACHED(); } |
66 | 67 |
67 void Add(const DeviceInfo* device) { devices_.push_back(device); } | 68 void Add(const DeviceInfo* device) { devices_.push_back(device); } |
68 | 69 |
69 private: | 70 private: |
70 // DeviceInfo stored here are not owned. | 71 // DeviceInfo stored here are not owned. |
71 std::vector<const DeviceInfo*> devices_; | 72 std::vector<const DeviceInfo*> devices_; |
72 }; | 73 }; |
73 | 74 |
74 TEST(SignedInDevicesAPITest, GetSignedInDevices) { | 75 TEST(SignedInDevicesAPITest, GetSignedInDevices) { |
| 76 content::TestBrowserThreadBundle thread_bundle; |
75 TestingProfile profile; | 77 TestingProfile profile; |
76 MockDeviceInfoTracker device_tracker; | 78 MockDeviceInfoTracker device_tracker; |
77 base::MessageLoop message_loop_; | 79 TestExtensionPrefs extension_prefs(base::ThreadTaskRunnerHandle::Get().get()); |
78 TestExtensionPrefs extension_prefs( | |
79 message_loop_.message_loop_proxy().get()); | |
80 | 80 |
81 // Add a couple of devices and make sure we get back public ids for them. | 81 // Add a couple of devices and make sure we get back public ids for them. |
82 std::string extension_name = "test"; | 82 std::string extension_name = "test"; |
83 scoped_refptr<Extension> extension_test = | 83 scoped_refptr<Extension> extension_test = |
84 extension_prefs.AddExtension(extension_name); | 84 extension_prefs.AddExtension(extension_name); |
85 | 85 |
86 DeviceInfo device_info1(base::GenerateGUID(), | 86 DeviceInfo device_info1(base::GenerateGUID(), |
87 "abc Device", | 87 "abc Device", |
88 "XYZ v1", | 88 "XYZ v1", |
89 "XYZ SyncAgent v1", | 89 "XYZ SyncAgent v1", |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 .WillOnce(Return(&device_tracker)); | 244 .WillOnce(Return(&device_tracker)); |
245 EXPECT_CALL(*pss_mock, Shutdown()); | 245 EXPECT_CALL(*pss_mock, Shutdown()); |
246 | 246 |
247 ScopedVector<DeviceInfo> output = GetAllSignedInDevices( | 247 ScopedVector<DeviceInfo> output = GetAllSignedInDevices( |
248 extension()->id(), profile()); | 248 extension()->id(), profile()); |
249 | 249 |
250 EXPECT_TRUE(output.empty()); | 250 EXPECT_TRUE(output.empty()); |
251 } | 251 } |
252 | 252 |
253 } // namespace extensions | 253 } // namespace extensions |
OLD | NEW |