1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/sync_driver/device_info_service.h"
#include <string>
#include "components/sync_driver/local_device_info_provider_mock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace sync_driver_v2 {
using sync_driver::DeviceInfo;
using sync_driver::DeviceInfoTracker;
using sync_driver::LocalDeviceInfoProviderMock;
namespace {
class DeviceInfoServiceTest : public testing::Test,
public DeviceInfoTracker::Observer {
protected:
DeviceInfoServiceTest() : num_device_info_changed_callbacks_(0) {}
void InitFully() {
local_device_.reset(new LocalDeviceInfoProviderMock(
"guid_1", "client_1", "Chromium 10k", "Chrome 10k",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id"));
service_.reset(new DeviceInfoService(local_device_.get()));
service_->AddObserver(this);
}
void InitPartially() {
local_device_.reset(new LocalDeviceInfoProviderMock());
service_.reset(new DeviceInfoService(local_device_.get()));
service_->AddObserver(this);
}
~DeviceInfoServiceTest() override { service_->RemoveObserver(this); }
void OnDeviceInfoChange() override { num_device_info_changed_callbacks_++; }
protected:
int num_device_info_changed_callbacks_;
scoped_ptr<LocalDeviceInfoProviderMock> local_device_;
scoped_ptr<DeviceInfoService> service_;
};
TEST_F(DeviceInfoServiceTest, StartSyncEmptyInitialData) {
InitFully();
EXPECT_FALSE(service_->IsSyncing());
}
TEST_F(DeviceInfoServiceTest, DelayedProviderInitialization) {
InitPartially();
local_device_->Initialize(make_scoped_ptr(
new DeviceInfo("guid_1", "client_1", "Chromium 10k", "Chrome 10k",
sync_pb::SyncEnums_DeviceType_TYPE_LINUX, "device_id")));
EXPECT_FALSE(service_->IsSyncing());
}
} // namespace
} // namespace sync_driver_v2
|