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

Side by Side Diff: chrome/browser/metrics/chromeos_metrics_provider_unittest.cc

Issue 289283015: Extract touchscreen device management into a generic manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 6 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 | Annotate | Revision Log
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 "chrome/browser/metrics/chromeos_metrics_provider.h" 5 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h"
9 #include "base/basictypes.h" 10 #include "base/basictypes.h"
10 #include "chrome/browser/chromeos/login/users/fake_user_manager.h" 11 #include "chrome/browser/chromeos/login/users/fake_user_manager.h"
11 #include "chrome/browser/chromeos/login/users/user_manager.h" 12 #include "chrome/browser/chromeos/login/users/user_manager.h"
12 #include "chrome/browser/metrics/chromeos_metrics_provider.h" 13 #include "chrome/browser/metrics/chromeos_metrics_provider.h"
13 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" 14 #include "chromeos/dbus/fake_bluetooth_adapter_client.h"
14 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h" 15 #include "chromeos/dbus/fake_bluetooth_agent_manager_client.h"
15 #include "chromeos/dbus/fake_bluetooth_device_client.h" 16 #include "chromeos/dbus/fake_bluetooth_device_client.h"
16 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h" 17 #include "chromeos/dbus/fake_bluetooth_gatt_characteristic_client.h"
17 #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h" 18 #include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h"
18 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h" 19 #include "chromeos/dbus/fake_bluetooth_gatt_service_client.h"
19 #include "chromeos/dbus/fake_bluetooth_input_client.h" 20 #include "chromeos/dbus/fake_bluetooth_input_client.h"
20 #include "chromeos/dbus/fake_dbus_thread_manager.h" 21 #include "chromeos/dbus/fake_dbus_thread_manager.h"
21 #include "chromeos/login/login_state.h" 22 #include "chromeos/login/login_state.h"
22 #include "components/metrics/proto/system_profile.pb.h" 23 #include "components/metrics/proto/system_profile.pb.h"
23 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
24 #include "content/public/test/test_utils.h" 25 #include "content/public/test/test_utils.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 27
28 #if defined(USE_X11)
29 #include "ui/events/x/device_data_manager_x11.h"
30 #endif
31
27 using chromeos::DBusThreadManager; 32 using chromeos::DBusThreadManager;
28 using chromeos::BluetoothAdapterClient; 33 using chromeos::BluetoothAdapterClient;
29 using chromeos::BluetoothAgentManagerClient; 34 using chromeos::BluetoothAgentManagerClient;
30 using chromeos::BluetoothDeviceClient; 35 using chromeos::BluetoothDeviceClient;
31 using chromeos::BluetoothGattCharacteristicClient; 36 using chromeos::BluetoothGattCharacteristicClient;
32 using chromeos::BluetoothGattDescriptorClient; 37 using chromeos::BluetoothGattDescriptorClient;
33 using chromeos::BluetoothGattServiceClient; 38 using chromeos::BluetoothGattServiceClient;
34 using chromeos::BluetoothInputClient; 39 using chromeos::BluetoothInputClient;
35 using chromeos::FakeBluetoothAdapterClient; 40 using chromeos::FakeBluetoothAdapterClient;
36 using chromeos::FakeBluetoothAgentManagerClient; 41 using chromeos::FakeBluetoothAgentManagerClient;
37 using chromeos::FakeBluetoothDeviceClient; 42 using chromeos::FakeBluetoothDeviceClient;
38 using chromeos::FakeBluetoothGattCharacteristicClient; 43 using chromeos::FakeBluetoothGattCharacteristicClient;
39 using chromeos::FakeBluetoothGattDescriptorClient; 44 using chromeos::FakeBluetoothGattDescriptorClient;
40 using chromeos::FakeBluetoothGattServiceClient; 45 using chromeos::FakeBluetoothGattServiceClient;
41 using chromeos::FakeBluetoothInputClient; 46 using chromeos::FakeBluetoothInputClient;
42 using chromeos::FakeDBusThreadManager; 47 using chromeos::FakeDBusThreadManager;
43 48
44 class ChromeOSMetricsProviderTest : public testing::Test { 49 class ChromeOSMetricsProviderTest : public testing::Test {
45 public: 50 public:
46 ChromeOSMetricsProviderTest() {} 51 ChromeOSMetricsProviderTest() {}
47 52
48 protected: 53 protected:
49 virtual void SetUp() OVERRIDE { 54 virtual void SetUp() OVERRIDE {
55 #if defined(USE_X11)
56 // AtExitManager keeps track of its lifetime.
57 new ui::DeviceDataManagerX11();
58 #endif
59
50 // Set up the fake Bluetooth environment, 60 // Set up the fake Bluetooth environment,
51 scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager( 61 scoped_ptr<FakeDBusThreadManager> fake_dbus_thread_manager(
52 new FakeDBusThreadManager); 62 new FakeDBusThreadManager);
53 fake_dbus_thread_manager->SetBluetoothAdapterClient( 63 fake_dbus_thread_manager->SetBluetoothAdapterClient(
54 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient)); 64 scoped_ptr<BluetoothAdapterClient>(new FakeBluetoothAdapterClient));
55 fake_dbus_thread_manager->SetBluetoothDeviceClient( 65 fake_dbus_thread_manager->SetBluetoothDeviceClient(
56 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient)); 66 scoped_ptr<BluetoothDeviceClient>(new FakeBluetoothDeviceClient));
57 fake_dbus_thread_manager->SetBluetoothGattCharacteristicClient( 67 fake_dbus_thread_manager->SetBluetoothGattCharacteristicClient(
58 scoped_ptr<BluetoothGattCharacteristicClient>( 68 scoped_ptr<BluetoothGattCharacteristicClient>(
59 new FakeBluetoothGattCharacteristicClient)); 69 new FakeBluetoothGattCharacteristicClient));
(...skipping 26 matching lines...) Expand all
86 chromeos::LoginState::Shutdown(); 96 chromeos::LoginState::Shutdown();
87 97
88 DBusThreadManager::Shutdown(); 98 DBusThreadManager::Shutdown();
89 } 99 }
90 100
91 protected: 101 protected:
92 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_; 102 FakeBluetoothAdapterClient* fake_bluetooth_adapter_client_;
93 FakeBluetoothDeviceClient* fake_bluetooth_device_client_; 103 FakeBluetoothDeviceClient* fake_bluetooth_device_client_;
94 104
95 private: 105 private:
106 base::ShadowingAtExitManager at_exit_;
sadrul 2014/06/16 14:48:37 Requiring all tests that use the DDMX11 to have a
dnicoara 2014/06/16 15:13:56 Only if DeviceDataManager allows calling CreateIns
sadrul 2014/06/17 20:37:08 We should avoid calling CreateInstance() from too
dnicoara 2014/06/18 14:04:29 Done.
96 content::TestBrowserThreadBundle thread_bundle_; 107 content::TestBrowserThreadBundle thread_bundle_;
97 108
98 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProviderTest); 109 DISALLOW_COPY_AND_ASSIGN(ChromeOSMetricsProviderTest);
99 }; 110 };
100 111
101 TEST_F(ChromeOSMetricsProviderTest, MultiProfileUserCount) { 112 TEST_F(ChromeOSMetricsProviderTest, MultiProfileUserCount) {
102 std::string user1("user1@example.com"); 113 std::string user1("user1@example.com");
103 std::string user2("user2@example.com"); 114 std::string user2("user2@example.com");
104 std::string user3("user3@example.com"); 115 std::string user3("user3@example.com");
105 116
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // Second device should match the Confirm Passkey object, this has 235 // Second device should match the Confirm Passkey object, this has
225 // no Device ID information. 236 // no Device ID information.
226 PairedDevice device2 = system_profile.hardware().bluetooth().paired_device(1); 237 PairedDevice device2 = system_profile.hardware().bluetooth().paired_device(1);
227 238
228 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass, 239 EXPECT_EQ(FakeBluetoothDeviceClient::kConfirmPasskeyClass,
229 device2.bluetooth_class()); 240 device2.bluetooth_class());
230 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type()); 241 EXPECT_EQ(PairedDevice::DEVICE_PHONE, device2.type());
231 EXPECT_EQ(0x207D74U, device2.vendor_prefix()); 242 EXPECT_EQ(0x207D74U, device2.vendor_prefix());
232 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source()); 243 EXPECT_EQ(PairedDevice::VENDOR_ID_UNKNOWN, device2.vendor_id_source());
233 } 244 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698