| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_incident.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signat
ure_incident.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/common/safe_browsing/csd.pb.h" | 11 #include "chrome/common/safe_browsing/csd.pb.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace safe_browsing { | 14 namespace safe_browsing { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 scoped_ptr<Incident> MakeIncident(bool alternate) { | 18 std::unique_ptr<Incident> MakeIncident(bool alternate) { |
| 18 scoped_ptr<ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident> | 19 std::unique_ptr< |
| 20 ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident> |
| 19 incident( | 21 incident( |
| 20 new ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident)
; | 22 new ClientIncidentReport_IncidentData_VariationsSeedSignatureIncident)
; |
| 21 if (alternate) { | 23 if (alternate) { |
| 22 incident->set_variations_seed_signature( | 24 incident->set_variations_seed_signature( |
| 23 "AEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2Gaz" | 25 "AEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2Gaz" |
| 24 "L7tXVLhURxUQcpiMg9eMLWO0U="); | 26 "L7tXVLhURxUQcpiMg9eMLWO0U="); |
| 25 } else { | 27 } else { |
| 26 incident->set_variations_seed_signature( | 28 incident->set_variations_seed_signature( |
| 27 "MEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2Gaz" | 29 "MEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2Gaz" |
| 28 "L7tXVLhURxUQcpiMg9eMLWO0U="); | 30 "L7tXVLhURxUQcpiMg9eMLWO0U="); |
| 29 } | 31 } |
| 30 return make_scoped_ptr( | 32 return base::WrapUnique( |
| 31 new VariationsSeedSignatureIncident(std::move(incident))); | 33 new VariationsSeedSignatureIncident(std::move(incident))); |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 TEST(VariationsSeedSignatureIncident, GetType) { | 38 TEST(VariationsSeedSignatureIncident, GetType) { |
| 37 ASSERT_EQ(IncidentType::VARIATIONS_SEED_SIGNATURE, | 39 ASSERT_EQ(IncidentType::VARIATIONS_SEED_SIGNATURE, |
| 38 MakeIncident(false)->GetType()); | 40 MakeIncident(false)->GetType()); |
| 39 } | 41 } |
| 40 | 42 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 MakeIncident(false)->ComputeDigest()); | 54 MakeIncident(false)->ComputeDigest()); |
| 53 } | 55 } |
| 54 | 56 |
| 55 // Tests that GetDigest returns different values for different incidents. | 57 // Tests that GetDigest returns different values for different incidents. |
| 56 TEST(VariationsSeedSignatureIncident, DifferentIncidentDifferentDigest) { | 58 TEST(VariationsSeedSignatureIncident, DifferentIncidentDifferentDigest) { |
| 57 EXPECT_NE(MakeIncident(false)->ComputeDigest(), | 59 EXPECT_NE(MakeIncident(false)->ComputeDigest(), |
| 58 MakeIncident(true)->ComputeDigest()); | 60 MakeIncident(true)->ComputeDigest()); |
| 59 } | 61 } |
| 60 | 62 |
| 61 } // namespace safe_browsing | 63 } // namespace safe_browsing |
| OLD | NEW |