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

Unified Diff: components/safe_browsing_db/testing_util.h

Issue 1726403006: Switch Safe Browsing's metadata from string to struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ParseJson in test Created 4 years, 10 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 | « components/safe_browsing_db/safe_browsing_api_handler_util.cc ('k') | components/safe_browsing_db/util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/testing_util.h
diff --git a/components/safe_browsing_db/testing_util.h b/components/safe_browsing_db/testing_util.h
new file mode 100644
index 0000000000000000000000000000000000000000..003051896055b77a26b2292d75082a8572eb6614
--- /dev/null
+++ b/components/safe_browsing_db/testing_util.h
@@ -0,0 +1,38 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Utilities to be used in tests of safe_browsing_db/ component.
+
+#ifndef COMPONENTS_SAFE_BROWSING_DB_TESTING_UTIL_H_
+#define COMPONENTS_SAFE_BROWSING_DB_TESTING_UTIL_H_
+
+#include "components/safe_browsing_db/util.h"
+
+#include <ostream>
+
+namespace safe_browsing {
+
+inline bool operator==(const ThreatMetadata& lhs, const ThreatMetadata& rhs) {
+ return lhs.threat_pattern_type == rhs.threat_pattern_type &&
+ lhs.api_permissions == rhs.api_permissions &&
+ lhs.population_id == rhs.population_id &&
+ lhs.raw_metadata == rhs.raw_metadata;
+}
+
+inline bool operator!=(const ThreatMetadata& lhs, const ThreatMetadata& rhs) {
+ return !(lhs == rhs);
+}
+
+inline std::ostream& operator<<(std::ostream& os, const ThreatMetadata& meta) {
+ os << "{threat_pattern_type=" << static_cast<int>(meta.threat_pattern_type)
+ << ", api_permissions=[";
+ for (auto p : meta.api_permissions)
+ os << p << ",";
+ return os << "], population_id=" << meta.population_id
+ << ", raw_metadata=" << meta.raw_metadata << "}";
+}
+
+} // namespace safe_browsing
+
+#endif // COMPONENTS_SAFE_BROWSING_DB_TESTING_UTIL_H_
« no previous file with comments | « components/safe_browsing_db/safe_browsing_api_handler_util.cc ('k') | components/safe_browsing_db/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698