| OLD | NEW |
| (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 |
| OLD | NEW |