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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/binary_integrity_incident_unittest.cc

Issue 1870003002: Convert //chrome/browser/safe_browsing from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments Created 4 years, 8 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
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
9 #include <memory>
8 #include <utility> 10 #include <utility>
9 11
10 #include "base/macros.h" 12 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/ptr_util.h"
12 #include "chrome/common/safe_browsing/csd.pb.h" 14 #include "chrome/common/safe_browsing/csd.pb.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 16
15 namespace safe_browsing { 17 namespace safe_browsing {
16 18
17 namespace { 19 namespace {
18 20
19 scoped_ptr<Incident> MakeIncident(const char* file_basename) { 21 std::unique_ptr<Incident> MakeIncident(const char* file_basename) {
20 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident> 22 std::unique_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>
21 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident); 23 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident);
22 24
23 incident->set_file_basename(file_basename); 25 incident->set_file_basename(file_basename);
24 26
25 // Set the signature. 27 // Set the signature.
26 incident->mutable_signature()->set_trusted(true); 28 incident->mutable_signature()->set_trusted(true);
27 ClientDownloadRequest_CertificateChain* certificate_chain = 29 ClientDownloadRequest_CertificateChain* certificate_chain =
28 incident->mutable_signature()->add_certificate_chain(); 30 incident->mutable_signature()->add_certificate_chain();
29 31
30 // Fill the certificate chain with 2 elements. 32 // Fill the certificate chain with 2 elements.
31 const unsigned char certificates[][5] = { 33 const unsigned char certificates[][5] = {
32 {42, 255, 100, 53, 2}, 34 {42, 255, 100, 53, 2},
33 {64, 33, 51, 91, 210}, 35 {64, 33, 51, 91, 210},
34 }; 36 };
35 for (size_t i = 0; i < arraysize(certificates); ++i) { 37 for (size_t i = 0; i < arraysize(certificates); ++i) {
36 ClientDownloadRequest_CertificateChain_Element* element = 38 ClientDownloadRequest_CertificateChain_Element* element =
37 certificate_chain->add_element(); 39 certificate_chain->add_element();
38 element->set_certificate(certificates[i], arraysize(certificates[i])); 40 element->set_certificate(certificates[i], arraysize(certificates[i]));
39 } 41 }
40 42
41 return make_scoped_ptr(new BinaryIntegrityIncident(std::move(incident))); 43 return base::WrapUnique(new BinaryIntegrityIncident(std::move(incident)));
42 } 44 }
43 45
44 } // namespace 46 } // namespace
45 47
46 TEST(BinaryIntegrityIncident, GetType) { 48 TEST(BinaryIntegrityIncident, GetType) {
47 ASSERT_EQ(IncidentType::BINARY_INTEGRITY, MakeIncident("foo")->GetType()); 49 ASSERT_EQ(IncidentType::BINARY_INTEGRITY, MakeIncident("foo")->GetType());
48 } 50 }
49 51
50 TEST(BinaryIntegrityIncident, GetKeyIsFile) { 52 TEST(BinaryIntegrityIncident, GetKeyIsFile) {
51 ASSERT_EQ(std::string("foo"), MakeIncident("foo")->GetKey()); 53 ASSERT_EQ(std::string("foo"), MakeIncident("foo")->GetKey());
52 } 54 }
53 55
54 TEST(BinaryIntegrityIncident, SameIncidentSameDigest) { 56 TEST(BinaryIntegrityIncident, SameIncidentSameDigest) {
55 ASSERT_EQ(MakeIncident("foo")->ComputeDigest(), 57 ASSERT_EQ(MakeIncident("foo")->ComputeDigest(),
56 MakeIncident("foo")->ComputeDigest()); 58 MakeIncident("foo")->ComputeDigest());
57 } 59 }
58 60
59 TEST(BinaryIntegrityIncident, DifferentIncidentDifferentDigest) { 61 TEST(BinaryIntegrityIncident, DifferentIncidentDifferentDigest) {
60 ASSERT_NE(MakeIncident("foo")->ComputeDigest(), 62 ASSERT_NE(MakeIncident("foo")->ComputeDigest(),
61 MakeIncident("bar")->ComputeDigest()); 63 MakeIncident("bar")->ComputeDigest());
62 } 64 }
63 65
64 } // namespace safe_browsing 66 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698