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

Unified Diff: chromeos/dbus/dbus_client_bundle_unittest.cc

Issue 2338063002: chromeos: Refactor D-Bus client type enum and stub vs. fake naming (Closed)
Patch Set: review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/dbus_client_bundle.cc ('k') | chromeos/dbus/dbus_client_implementation_type.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/dbus_client_bundle_unittest.cc
diff --git a/chromeos/dbus/dbus_client_bundle_unittest.cc b/chromeos/dbus/dbus_client_bundle_unittest.cc
index bfc439b59504e481d359e73b253134942724a139..a1423e682595efe24b6b3aead439d9f275e4e6dd 100644
--- a/chromeos/dbus/dbus_client_bundle_unittest.cc
+++ b/chromeos/dbus/dbus_client_bundle_unittest.cc
@@ -4,35 +4,60 @@
#include "chromeos/dbus/dbus_client_bundle.h"
-#include "base/compiler_specific.h"
+#include "chromeos/dbus/dbus_client_types.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
+namespace {
-TEST(DBusClientBundleTest, UnstubFlagParser) {
- EXPECT_EQ(0, DBusClientBundle::ParseUnstubList("foo"));
-
- EXPECT_EQ(DBusClientBundle::BLUETOOTH,
- DBusClientBundle::ParseUnstubList("BLUETOOTH"));
-
- EXPECT_EQ(DBusClientBundle::BLUETOOTH,
- DBusClientBundle::ParseUnstubList("bluetooth"));
-
- EXPECT_EQ(
- DBusClientBundle::CRAS |
- DBusClientBundle::CROS_DISKS |
- DBusClientBundle::DEBUG_DAEMON |
- DBusClientBundle::SHILL,
- DBusClientBundle::ParseUnstubList(
- "Cras,Cros_Disks,debug_daemon,Shill"));
-
- EXPECT_EQ(
- DBusClientBundle::CRAS |
- DBusClientBundle::CROS_DISKS |
- DBusClientBundle::DEBUG_DAEMON |
- DBusClientBundle::SHILL,
- DBusClientBundle::ParseUnstubList(
- "foo,Cras,Cros_Disks,debug_daemon,Shill"));
+// Makes mask operations more readable.
+DBusClientTypeMask AsClientTypeMask(DBusClientType type) {
+ return static_cast<DBusClientTypeMask>(type);
+}
+
+} // namespace
+
+// Tests that real and fake clients can be created.
+TEST(DBusClientBundleTest, CreateClientBundle) {
+ const DBusClientTypeMask real_clients =
+ AsClientTypeMask(DBusClientType::CRAS) |
+ AsClientTypeMask(DBusClientType::CROS_DISKS);
+ DBusClientBundle bundle(real_clients);
+
+ // Real clients are real.
+ EXPECT_TRUE(bundle.cras_audio_client());
+ EXPECT_TRUE(bundle.cros_disks_client());
+ EXPECT_TRUE(bundle.IsUsingReal(DBusClientType::CRAS));
+ EXPECT_TRUE(bundle.IsUsingReal(DBusClientType::CROS_DISKS));
+
+ // Fake clients are fake.
+ EXPECT_TRUE(bundle.permission_broker_client());
+ EXPECT_TRUE(bundle.power_manager_client());
+ EXPECT_FALSE(bundle.IsUsingReal(DBusClientType::PERMISSION_BROKER));
+ EXPECT_FALSE(bundle.IsUsingReal(DBusClientType::POWER_MANAGER));
+}
+
+TEST(DBusClientBundleTest, RealClientsFlagParser) {
+ EXPECT_EQ(AsClientTypeMask(DBusClientType::NONE),
+ ParseDBusRealClientsList("foo"));
+
+ EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH),
+ ParseDBusRealClientsList("BLUETOOTH"));
+
+ EXPECT_EQ(AsClientTypeMask(DBusClientType::BLUETOOTH),
+ ParseDBusRealClientsList("bluetooth"));
+
+ EXPECT_EQ(AsClientTypeMask(DBusClientType::CRAS) |
+ AsClientTypeMask(DBusClientType::CROS_DISKS) |
+ AsClientTypeMask(DBusClientType::DEBUG_DAEMON) |
+ AsClientTypeMask(DBusClientType::SHILL),
+ ParseDBusRealClientsList("Cras,Cros_Disks,debug_daemon,Shill"));
+
+ EXPECT_EQ(AsClientTypeMask(DBusClientType::CRAS) |
+ AsClientTypeMask(DBusClientType::CROS_DISKS) |
+ AsClientTypeMask(DBusClientType::DEBUG_DAEMON) |
+ AsClientTypeMask(DBusClientType::SHILL),
+ ParseDBusRealClientsList("foo,Cras,Cros_Disks,debug_daemon,Shill"));
}
} // namespace chromeos
« no previous file with comments | « chromeos/dbus/dbus_client_bundle.cc ('k') | chromeos/dbus/dbus_client_implementation_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698