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

Unified Diff: chromeos/dbus/biod/biod_client_unittest.cc

Issue 2581403002: cros: Remaining interfaces for DBUS biometrics client. (Closed)
Patch Set: Rebased. Created 3 years, 9 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/biod/biod_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/biod/biod_client_unittest.cc
diff --git a/chromeos/dbus/biod/biod_client_unittest.cc b/chromeos/dbus/biod/biod_client_unittest.cc
index eccbeafb7912eb146eb92f0b8507810a128f2d5f..ec86d098b77081aed6d556f4d4493677ea977746 100644
--- a/chromeos/dbus/biod/biod_client_unittest.cc
+++ b/chromeos/dbus/biod/biod_client_unittest.cc
@@ -30,6 +30,10 @@ const char* kInterface = biod::kBiometricsManagerInterface;
// to determine when empty values have been assigned.
const char kInvalidTestPath[] = "/invalid/test/path";
+// Value used to intialize string objects in tests to make it easier to
+// determine when empty values have been assigned.
+const char kInvalidString[] = "invalidString";
+
void CopyObjectPath(dbus::ObjectPath* dest_path,
const dbus::ObjectPath& src_path) {
CHECK(dest_path);
@@ -43,6 +47,11 @@ void CopyObjectPathArray(
*dest_object_paths = src_object_paths;
}
+void CopyString(std::string* dest_str, const std::string& src_str) {
+ CHECK(dest_str);
+ *dest_str = src_str;
+}
+
// Matcher that verifies that a dbus::Message has member |name|.
MATCHER_P(HasMember, name, "") {
if (arg->GetMember() != name) {
@@ -110,9 +119,7 @@ class BiodClientTest : public testing::Test {
// |client_|'s Init() method should request a proxy for communicating with
// biometrics api.
- EXPECT_CALL(*bus_.get(),
- GetObjectProxy(biod::kBiodServiceName,
- dbus::ObjectPath(biod::kBiodServicePath)))
+ EXPECT_CALL(*bus_.get(), GetObjectProxy(biod::kBiodServiceName, _))
.WillRepeatedly(Return(proxy_.get()));
// Save |client_|'s signal callback.
@@ -284,7 +291,7 @@ TEST_F(BiodClientTest, TestGetRecordsForUser) {
writer.AppendArrayOfObjectPaths(kFakeObjectPaths);
// Create a fake response with an array of fake object paths. The get
- // enrollments call should return this array of object paths.
+ // records for user call should return this array of object paths.
AddMethodExpectation(biod::kBiometricsManagerGetRecordsForUserMethod,
std::move(response));
std::vector<dbus::ObjectPath> returned_object_paths = {
@@ -371,4 +378,31 @@ TEST_F(BiodClientTest, TestNotifyObservers) {
EXPECT_EQ(1, observer.num_auth_scans_received());
EXPECT_EQ(1, observer.num_failures_received());
}
+
+TEST_F(BiodClientTest, TestGetRecordLabel) {
+ const std::string kFakeLabel("fakeLabel");
+ const dbus::ObjectPath kFakeRecordPath(std::string("/fake/record/path"));
+
+ std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
+ dbus::MessageWriter writer(response.get());
+ writer.AppendString(kFakeLabel);
+
+ // Create a fake response with string. The get label call should return this
+ // exact string.
+ std::string returned_label = kInvalidString;
+ AddMethodExpectation(dbus::kDBusPropertiesGet, std::move(response));
+ client_->RequestRecordLabel(kFakeRecordPath,
+ base::Bind(&CopyString, &returned_label));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(kFakeLabel, returned_label);
+
+ // Verify that by sending a empty reponse the response is an empty string.
+ // Also, logs will get printed.
+ returned_label = kInvalidString;
+ AddMethodExpectation(dbus::kDBusPropertiesGet, nullptr);
+ client_->RequestRecordLabel(kFakeRecordPath,
+ base::Bind(&CopyString, &returned_label));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ("", returned_label);
+}
} // namespace chromeos
« no previous file with comments | « chromeos/dbus/biod/biod_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698