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/binary_integrity_incid
ent.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid
ent.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "chrome/common/safe_browsing/csd.pb.h" | 12 #include "chrome/common/safe_browsing/csd.pb.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace safe_browsing { | 15 namespace safe_browsing { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
(...skipping 12 matching lines...) Expand all Loading... |
30 const unsigned char certificates[][5] = { | 31 const unsigned char certificates[][5] = { |
31 {42, 255, 100, 53, 2}, | 32 {42, 255, 100, 53, 2}, |
32 {64, 33, 51, 91, 210}, | 33 {64, 33, 51, 91, 210}, |
33 }; | 34 }; |
34 for (size_t i = 0; i < arraysize(certificates); ++i) { | 35 for (size_t i = 0; i < arraysize(certificates); ++i) { |
35 ClientDownloadRequest_CertificateChain_Element* element = | 36 ClientDownloadRequest_CertificateChain_Element* element = |
36 certificate_chain->add_element(); | 37 certificate_chain->add_element(); |
37 element->set_certificate(certificates[i], arraysize(certificates[i])); | 38 element->set_certificate(certificates[i], arraysize(certificates[i])); |
38 } | 39 } |
39 | 40 |
40 return make_scoped_ptr(new BinaryIntegrityIncident(incident.Pass())); | 41 return make_scoped_ptr(new BinaryIntegrityIncident(std::move(incident))); |
41 } | 42 } |
42 | 43 |
43 } // namespace | 44 } // namespace |
44 | 45 |
45 TEST(BinaryIntegrityIncident, GetType) { | 46 TEST(BinaryIntegrityIncident, GetType) { |
46 ASSERT_EQ(IncidentType::BINARY_INTEGRITY, MakeIncident("foo")->GetType()); | 47 ASSERT_EQ(IncidentType::BINARY_INTEGRITY, MakeIncident("foo")->GetType()); |
47 } | 48 } |
48 | 49 |
49 TEST(BinaryIntegrityIncident, GetKeyIsFile) { | 50 TEST(BinaryIntegrityIncident, GetKeyIsFile) { |
50 ASSERT_EQ(std::string("foo"), MakeIncident("foo")->GetKey()); | 51 ASSERT_EQ(std::string("foo"), MakeIncident("foo")->GetKey()); |
51 } | 52 } |
52 | 53 |
53 TEST(BinaryIntegrityIncident, SameIncidentSameDigest) { | 54 TEST(BinaryIntegrityIncident, SameIncidentSameDigest) { |
54 ASSERT_EQ(MakeIncident("foo")->ComputeDigest(), | 55 ASSERT_EQ(MakeIncident("foo")->ComputeDigest(), |
55 MakeIncident("foo")->ComputeDigest()); | 56 MakeIncident("foo")->ComputeDigest()); |
56 } | 57 } |
57 | 58 |
58 TEST(BinaryIntegrityIncident, DifferentIncidentDifferentDigest) { | 59 TEST(BinaryIntegrityIncident, DifferentIncidentDifferentDigest) { |
59 ASSERT_NE(MakeIncident("foo")->ComputeDigest(), | 60 ASSERT_NE(MakeIncident("foo")->ComputeDigest(), |
60 MakeIncident("bar")->ComputeDigest()); | 61 MakeIncident("bar")->ComputeDigest()); |
61 } | 62 } |
62 | 63 |
63 } // namespace safe_browsing | 64 } // namespace safe_browsing |
OLD | NEW |