| 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 "chromeos/dbus/dbus_client_bundle.h" | 5 #include "chromeos/dbus/dbus_client_bundle.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "chromeos/dbus/dbus_client_types.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace chromeos { | 10 namespace chromeos { |
| 11 namespace { |
| 12 |
| 13 // Makes mask operations more readable. |
| 14 DBusClientTypeMask AsClientTypeMask(DBusClientType type) { |
| 15 return static_cast<DBusClientTypeMask>(type); |
| 16 } |
| 17 |
| 18 } // namespace |
| 19 |
| 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 } |
| 11 | 39 |
| 12 TEST(DBusClientBundleTest, UnstubFlagParser) { | 40 TEST(DBusClientBundleTest, UnstubFlagParser) { |
| 13 EXPECT_EQ(0, DBusClientBundle::ParseUnstubList("foo")); | 41 EXPECT_EQ(0, ParseDBusUnstubClientsList("foo")); |
| 14 | 42 |
| 15 EXPECT_EQ(DBusClientBundle::BLUETOOTH, | 43 EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH), |
| 16 DBusClientBundle::ParseUnstubList("BLUETOOTH")); | 44 ParseDBusUnstubClientsList("BLUETOOTH")); |
| 17 | 45 |
| 18 EXPECT_EQ(DBusClientBundle::BLUETOOTH, | 46 EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH), |
| 19 DBusClientBundle::ParseUnstubList("bluetooth")); | 47 ParseDBusUnstubClientsList("bluetooth")); |
| 48 |
| 49 EXPECT_EQ(AsClientTypeMask(DBusClientType::CRAS) | |
| 50 AsClientTypeMask(DBusClientType::CROS_DISKS) | |
| 51 AsClientTypeMask(DBusClientType::DEBUG_DAEMON) | |
| 52 AsClientTypeMask(DBusClientType::SHILL), |
| 53 ParseDBusUnstubClientsList("Cras,Cros_Disks,debug_daemon,Shill")); |
| 20 | 54 |
| 21 EXPECT_EQ( | 55 EXPECT_EQ( |
| 22 DBusClientBundle::CRAS | | 56 AsClientTypeMask(DBusClientType::CRAS) | |
| 23 DBusClientBundle::CROS_DISKS | | 57 AsClientTypeMask(DBusClientType::CROS_DISKS) | |
| 24 DBusClientBundle::DEBUG_DAEMON | | 58 AsClientTypeMask(DBusClientType::DEBUG_DAEMON) | |
| 25 DBusClientBundle::SHILL, | 59 AsClientTypeMask(DBusClientType::SHILL), |
| 26 DBusClientBundle::ParseUnstubList( | 60 ParseDBusUnstubClientsList("foo,Cras,Cros_Disks,debug_daemon,Shill")); |
| 27 "Cras,Cros_Disks,debug_daemon,Shill")); | |
| 28 | |
| 29 EXPECT_EQ( | |
| 30 DBusClientBundle::CRAS | | |
| 31 DBusClientBundle::CROS_DISKS | | |
| 32 DBusClientBundle::DEBUG_DAEMON | | |
| 33 DBusClientBundle::SHILL, | |
| 34 DBusClientBundle::ParseUnstubList( | |
| 35 "foo,Cras,Cros_Disks,debug_daemon,Shill")); | |
| 36 } | 61 } |
| 37 | 62 |
| 38 } // namespace chromeos | 63 } // namespace chromeos |
| OLD | NEW |