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

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

Issue 856543004: Replace incident type handlers with implementations of Incident. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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_unittest.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..369a6d28372957e7ab1317a5c583e873f543db55
--- /dev/null
+++ b/chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident_unittest.cc
@@ -0,0 +1,45 @@
+// Copyright 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.
+
+#include "chrome/browser/safe_browsing/incident_reporting/blacklist_load_incident.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace safe_browsing {
+
+namespace {
+
+scoped_ptr<Incident> MakeIncident(const char* digest) {
+ scoped_ptr<ClientIncidentReport_IncidentData_BlacklistLoadIncident> incident(
+ new ClientIncidentReport_IncidentData_BlacklistLoadIncident);
+ incident->set_path("foo");
+ return make_scoped_ptr(new BlacklistLoadIncident(incident.Pass()));
+}
+
+} // namespace
+
+TEST(BlacklistLoadIncident, GetType) {
+ ASSERT_EQ(IncidentType::BLACKLIST_LOAD, MakeIncident("37")->GetType());
+}
+
+// Tests that GetKey returns the dll path.
+TEST(BlacklistLoadIncident, KeyIsPath) {
+ ASSERT_EQ(std::string("foo"), MakeIncident("37")->GetKey());
+}
+
+// Tests that GetDigest returns the same value for the same incident.
+TEST(BlacklistLoadIncident, SameIncidentSameDigest) {
+ ASSERT_EQ(MakeIncident("37")->ComputeDigest(),
+ MakeIncident("37")->ComputeDigest());
+}
+
+// Tests that GetDigest returns different values for different incidents.
+TEST(BlacklistLoadIncident, DifferentIncidentDifferentDigest) {
+ ASSERT_EQ(MakeIncident("37")->ComputeDigest(),
+ MakeIncident("42")->ComputeDigest());
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698