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

Unified Diff: components/password_manager/core/browser/password_manager_test_utils.h

Issue 1022823002: Make test outputs involving PasswordForms more readable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
Index: components/password_manager/core/browser/password_manager_test_utils.h
diff --git a/components/password_manager/core/browser/password_manager_test_utils.h b/components/password_manager/core/browser/password_manager_test_utils.h
index 71599a446b8a0dfab35e83201e9b1c91741b5fd1..b1600bdbf5dad3204c273b4da2354f008a698994 100644
--- a/components/password_manager/core/browser/password_manager_test_utils.h
+++ b/components/password_manager/core/browser/password_manager_test_utils.h
@@ -5,6 +5,7 @@
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_TEST_UTILS_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_TEST_UTILS_H_
+#include <iosfwd>
#include <vector>
#include "base/memory/scoped_ptr.h"
@@ -42,17 +43,19 @@ struct PasswordFormData {
scoped_ptr<autofill::PasswordForm> CreatePasswordFormFromDataForTesting(
const PasswordFormData& form_data);
-// Checks whether two vectors of PasswordForms contain equivalent elements,
-// regardless of order.
-// TODO(vabr) The *Ptr suffix is obsolete, rename.
-bool ContainsSamePasswordFormsPtr(
- const std::vector<autofill::PasswordForm*>& first,
- const std::vector<autofill::PasswordForm*>& second);
-
-// This gmock matcher is used to check that the |arg| contains exactly the same
-// PasswordForms as |forms|, regardless of order.
-MATCHER_P(ContainsSamePasswordForms, forms, "") {
- return ContainsSamePasswordFormsPtr(forms, arg);
+// Checks whether |actual_values| contains pointers to PasswordForms that are in
+// some order pairwise equal to those in |expectations|. Details of mismatches
+// will be written in human readable form to |mismatches_output| if not NULL.
vabr (Chromium) 2015/03/19 13:28:12 optional nit: "if not NULL" -> "unless it is NULL"
engedy 2015/03/20 13:17:15 Both done.
+bool ContainsEqualPasswordFormsUnordered(
+ const std::vector<autofill::PasswordForm*>& expectations,
+ const std::vector<autofill::PasswordForm*>& actual_values,
+ std::ostream* mismatches_output);
+
+// GMock matcher that matches an |arg| containing pointers to PasswordForms that
+// are equal to those in |forms|, regardless of order.
vabr (Chromium) 2015/03/19 13:28:12 forms -> expected_forms
vabr (Chromium) 2015/03/19 13:28:12 "equal to those in |forms|" sounds a bit incorrect
engedy 2015/03/20 13:17:15 N/A anymore.
engedy 2015/03/20 13:17:15 Done. I have updated the comment above, and comple
+MATCHER_P(UnorderedPasswordFormElementsAre, expected_forms, "") {
+ return ContainsEqualPasswordFormsUnordered(expected_forms, arg,
+ result_listener->stream());
}
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698