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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/tracked_preference_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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_inc ident.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/common/safe_browsing/csd.pb.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace safe_browsing {
12
13 namespace {
14
15 scoped_ptr<Incident> MakeIncident(bool changed) {
16 scoped_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident>
17 incident(new ClientIncidentReport_IncidentData_TrackedPreferenceIncident);
18
19 incident->set_path("foo");
20 incident->set_atomic_value("bar");
21 incident->set_value_state(
22 changed
23 ? ClientIncidentReport_IncidentData_TrackedPreferenceIncident_ValueSta te_CHANGED
24 : ClientIncidentReport_IncidentData_TrackedPreferenceIncident_ValueSta te_CLEARED);
25 return make_scoped_ptr(new TrackedPreferenceIncident(incident.Pass()));
26 }
27
28 } // namespace
29
30 TEST(TrackedPreferenceIncident, GetType) {
31 ASSERT_EQ(IncidentType::TRACKED_PREFERENCE, MakeIncident(false)->GetType());
32 }
33
34 // Tests that GetKey returns the preference path.
35 TEST(TrackedPreferenceIncident, KeyIsPath) {
36 ASSERT_EQ(std::string("foo"), MakeIncident(false)->GetKey());
37 }
38
39 // Tests that GetDigest returns the same value for the same incident.
40 TEST(TrackedPreferenceIncident, SameIncidentSameDigest) {
41 ASSERT_EQ(MakeIncident(false)->ComputeDigest(),
42 MakeIncident(false)->ComputeDigest());
43 }
44
45 // Tests that GetDigest returns a different value for different incidents.
46 TEST(TrackedPreferenceIncident, DifferentIncidentDifferentDigest) {
47 ASSERT_NE(MakeIncident(false)->ComputeDigest(),
48 MakeIncident(true)->ComputeDigest());
49 }
50
51 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698