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

Side by Side Diff: chromeos/dbus/dbus_client_bundle_unittest.cc

Issue 2343993003: chromeos: Refactor D-Bus client creation for ash and browser processes (Closed)
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « chromeos/dbus/dbus_client_bundle.cc ('k') | chromeos/dbus/dbus_clients_browser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chromeos/dbus/dbus_client_bundle.h"
6
7 #include "chromeos/dbus/dbus_client_types.h" 5 #include "chromeos/dbus/dbus_client_types.h"
8 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
9 7
10 namespace chromeos { 8 namespace chromeos {
11 namespace { 9 namespace {
12 10
13 // Makes mask operations more readable. 11 // Makes mask operations more readable.
14 DBusClientTypeMask AsClientTypeMask(DBusClientType type) { 12 DBusClientTypeMask AsClientTypeMask(DBusClientType type) {
15 return static_cast<DBusClientTypeMask>(type); 13 return static_cast<DBusClientTypeMask>(type);
16 } 14 }
17 15
18 } // namespace 16 } // namespace
19 17
20 // Tests that real and fake clients can be created.
21 TEST(DBusClientBundleTest, CreateClientBundle) {
22 const DBusClientTypeMask real_clients =
23 AsClientTypeMask(DBusClientType::CRAS) |
24 AsClientTypeMask(DBusClientType::CROS_DISKS);
25 DBusClientBundle bundle(real_clients);
26
27 // Real clients are real.
28 EXPECT_TRUE(bundle.cras_audio_client());
29 EXPECT_TRUE(bundle.cros_disks_client());
30 EXPECT_TRUE(bundle.IsUsingReal(DBusClientType::CRAS));
31 EXPECT_TRUE(bundle.IsUsingReal(DBusClientType::CROS_DISKS));
32
33 // Fake clients are fake.
34 EXPECT_TRUE(bundle.permission_broker_client());
35 EXPECT_TRUE(bundle.power_manager_client());
36 EXPECT_FALSE(bundle.IsUsingReal(DBusClientType::PERMISSION_BROKER));
37 EXPECT_FALSE(bundle.IsUsingReal(DBusClientType::POWER_MANAGER));
38 }
39
40 TEST(DBusClientBundleTest, RealClientsFlagParser) { 18 TEST(DBusClientBundleTest, RealClientsFlagParser) {
41 EXPECT_EQ(AsClientTypeMask(DBusClientType::NONE), 19 EXPECT_EQ(AsClientTypeMask(DBusClientType::NONE),
42 ParseDBusRealClientsList("foo")); 20 ParseDBusRealClientsList("foo"));
43 21
44 EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH), 22 EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH),
45 ParseDBusRealClientsList("BLUETOOTH")); 23 ParseDBusRealClientsList("BLUETOOTH"));
46 24
47 EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH), 25 EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH),
48 ParseDBusRealClientsList("bluetooth")); 26 ParseDBusRealClientsList("bluetooth"));
49 27
50 EXPECT_EQ(AsClientTypeMask(DBusClientType::CRAS) | 28 EXPECT_EQ(AsClientTypeMask(DBusClientType::CRAS) |
51 AsClientTypeMask(DBusClientType::CROS_DISKS) | 29 AsClientTypeMask(DBusClientType::CROS_DISKS) |
52 AsClientTypeMask(DBusClientType::DEBUG_DAEMON) | 30 AsClientTypeMask(DBusClientType::DEBUG_DAEMON) |
53 AsClientTypeMask(DBusClientType::SHILL), 31 AsClientTypeMask(DBusClientType::SHILL),
54 ParseDBusRealClientsList("Cras,Cros_Disks,debug_daemon,Shill")); 32 ParseDBusRealClientsList("Cras,Cros_Disks,debug_daemon,Shill"));
55 33
56 EXPECT_EQ(AsClientTypeMask(DBusClientType::CRAS) | 34 EXPECT_EQ(AsClientTypeMask(DBusClientType::CRAS) |
57 AsClientTypeMask(DBusClientType::CROS_DISKS) | 35 AsClientTypeMask(DBusClientType::CROS_DISKS) |
58 AsClientTypeMask(DBusClientType::DEBUG_DAEMON) | 36 AsClientTypeMask(DBusClientType::DEBUG_DAEMON) |
59 AsClientTypeMask(DBusClientType::SHILL), 37 AsClientTypeMask(DBusClientType::SHILL),
60 ParseDBusRealClientsList("foo,Cras,Cros_Disks,debug_daemon,Shill")); 38 ParseDBusRealClientsList("foo,Cras,Cros_Disks,debug_daemon,Shill"));
61 } 39 }
62 40
63 } // namespace chromeos 41 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_client_bundle.cc ('k') | chromeos/dbus/dbus_clients_browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698