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

Unified Diff: chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_handlers_unittest.cc

Issue 433513008: Add blacklist incidents to incident reporting service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mattm feedback Created 6 years, 4 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: chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_handlers_unittest.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_handlers_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_handlers_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b63349fd7c8878b6e40f24644c3640753966dafe
--- /dev/null
+++ b/chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_handlers_unittest.cc
@@ -0,0 +1,61 @@
+// Copyright 2014 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.
+
+#include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_handlers.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> MakeIncident() {
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident(
+ new safe_browsing::ClientIncidentReport_IncidentData);
+ incident->mutable_blacklist_load()->set_path("foo");
+ return incident.Pass();
+}
+
+} // namespace
+
+// Tests that GetKey returns the dll path.
+TEST(GetBlacklistLoadIncidentKey, KeyIsPath) {
+ safe_browsing::ClientIncidentReport_IncidentData incident;
+
+ incident.mutable_blacklist_load()->set_path("foo");
+ ASSERT_EQ(std::string("foo"),
+ safe_browsing::GetBlacklistLoadIncidentKey(incident));
+}
+
+// Tests that GetDigest returns the same value for the same incident.
+TEST(GetBlacklistLoadIncidentDigest, SameIncidentSameDigest) {
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident(
+ MakeIncident());
+
+ uint32_t digest = safe_browsing::GetBlacklistLoadIncidentDigest(*incident);
+ ASSERT_EQ(digest,
+ safe_browsing::GetBlacklistLoadIncidentDigest(*MakeIncident()));
+}
+
+// Tests that GetDigest returns different values for different incidents.
+TEST(GetBlacklistLoadIncidentDigest, DifferentIncidentDifferentDigest) {
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident(
+ MakeIncident());
+ scoped_ptr<safe_browsing::ClientDownloadRequest_Digests> digest_proto(
+ new safe_browsing::ClientDownloadRequest_Digests);
+ digest_proto->set_sha256("37");
+ incident->mutable_blacklist_load()->set_allocated_digest(
+ digest_proto.release());
+
+ scoped_ptr<safe_browsing::ClientIncidentReport_IncidentData> incident2(
+ MakeIncident());
+ scoped_ptr<safe_browsing::ClientDownloadRequest_Digests> digest_proto2(
+ new safe_browsing::ClientDownloadRequest_Digests);
+ digest_proto2->set_sha256("42");
+ incident2->mutable_blacklist_load()->set_allocated_digest(
+ digest_proto2.release());
+
+ ASSERT_NE(safe_browsing::GetBlacklistLoadIncidentDigest(*incident),
+ safe_browsing::GetBlacklistLoadIncidentDigest(*incident2));
+}

Powered by Google App Engine
This is Rietveld 408576698