| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/preference_validation_
delegate.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/preference_validation_
delegate.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | |
| 9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" | 16 #include "chrome/browser/safe_browsing/incident_reporting/incident.h" |
| 17 #include "chrome/browser/safe_browsing/incident_reporting/mock_incident_receiver
.h" | 17 #include "chrome/browser/safe_browsing/incident_reporting/mock_incident_receiver
.h" |
| 18 #include "chrome/common/safe_browsing/csd.pb.h" | 18 #include "chrome/common/safe_browsing/csd.pb.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 void SetUp() override { | 38 void SetUp() override { |
| 39 testing::Test::SetUp(); | 39 testing::Test::SetUp(); |
| 40 invalid_keys_.push_back(std::string("one")); | 40 invalid_keys_.push_back(std::string("one")); |
| 41 invalid_keys_.push_back(std::string("two")); | 41 invalid_keys_.push_back(std::string("two")); |
| 42 scoped_ptr<safe_browsing::MockIncidentReceiver> receiver( | 42 scoped_ptr<safe_browsing::MockIncidentReceiver> receiver( |
| 43 new NiceMock<safe_browsing::MockIncidentReceiver>()); | 43 new NiceMock<safe_browsing::MockIncidentReceiver>()); |
| 44 ON_CALL(*receiver, DoAddIncidentForProfile(IsNull(), _)) | 44 ON_CALL(*receiver, DoAddIncidentForProfile(IsNull(), _)) |
| 45 .WillByDefault(WithArg<1>(TakeIncidentToVector(&incidents_))); | 45 .WillByDefault(WithArg<1>(TakeIncidentToVector(&incidents_))); |
| 46 instance_.reset(new safe_browsing::PreferenceValidationDelegate( | 46 instance_.reset(new safe_browsing::PreferenceValidationDelegate( |
| 47 nullptr, receiver.Pass())); | 47 nullptr, std::move(receiver))); |
| 48 } | 48 } |
| 49 | 49 |
| 50 static void ExpectValueStatesEquate( | 50 static void ExpectValueStatesEquate( |
| 51 PrefHashStoreTransaction::ValueState store_state, | 51 PrefHashStoreTransaction::ValueState store_state, |
| 52 safe_browsing:: | 52 safe_browsing:: |
| 53 ClientIncidentReport_IncidentData_TrackedPreferenceIncident_ValueState | 53 ClientIncidentReport_IncidentData_TrackedPreferenceIncident_ValueState |
| 54 incident_state) { | 54 incident_state) { |
| 55 typedef safe_browsing:: | 55 typedef safe_browsing:: |
| 56 ClientIncidentReport_IncidentData_TrackedPreferenceIncident TPIncident; | 56 ClientIncidentReport_IncidentData_TrackedPreferenceIncident TPIncident; |
| 57 switch (store_state) { | 57 switch (store_state) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 case Value::TYPE_INTEGER: | 126 case Value::TYPE_INTEGER: |
| 127 return scoped_ptr<Value>(new base::FundamentalValue(47)); | 127 return scoped_ptr<Value>(new base::FundamentalValue(47)); |
| 128 case Value::TYPE_DOUBLE: | 128 case Value::TYPE_DOUBLE: |
| 129 return scoped_ptr<Value>(new base::FundamentalValue(0.47)); | 129 return scoped_ptr<Value>(new base::FundamentalValue(0.47)); |
| 130 case Value::TYPE_STRING: | 130 case Value::TYPE_STRING: |
| 131 return scoped_ptr<Value>(new base::StringValue("i have a spleen")); | 131 return scoped_ptr<Value>(new base::StringValue("i have a spleen")); |
| 132 case Value::TYPE_DICTIONARY: { | 132 case Value::TYPE_DICTIONARY: { |
| 133 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 133 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 134 value->SetInteger("twenty-two", 22); | 134 value->SetInteger("twenty-two", 22); |
| 135 value->SetInteger("forty-seven", 47); | 135 value->SetInteger("forty-seven", 47); |
| 136 return value.Pass(); | 136 return std::move(value); |
| 137 } | 137 } |
| 138 case Value::TYPE_LIST: { | 138 case Value::TYPE_LIST: { |
| 139 scoped_ptr<base::ListValue> value(new base::ListValue()); | 139 scoped_ptr<base::ListValue> value(new base::ListValue()); |
| 140 value->AppendInteger(22); | 140 value->AppendInteger(22); |
| 141 value->AppendInteger(47); | 141 value->AppendInteger(47); |
| 142 return value.Pass(); | 142 return std::move(value); |
| 143 } | 143 } |
| 144 default: | 144 default: |
| 145 ADD_FAILURE() << "unsupported value type " << value_type; | 145 ADD_FAILURE() << "unsupported value type " << value_type; |
| 146 } | 146 } |
| 147 return scoped_ptr<Value>(); | 147 return scoped_ptr<Value>(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 base::Value::Type value_type_; | 150 base::Value::Type value_type_; |
| 151 const char* expected_value_; | 151 const char* expected_value_; |
| 152 }; | 152 }; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 282 } |
| 283 | 283 |
| 284 INSTANTIATE_TEST_CASE_P( | 284 INSTANTIATE_TEST_CASE_P( |
| 285 WithIncident, | 285 WithIncident, |
| 286 PreferenceValidationDelegateWithIncident, | 286 PreferenceValidationDelegateWithIncident, |
| 287 testing::Combine( | 287 testing::Combine( |
| 288 testing::Values(PrefHashStoreTransaction::CLEARED, | 288 testing::Values(PrefHashStoreTransaction::CLEARED, |
| 289 PrefHashStoreTransaction::CHANGED, | 289 PrefHashStoreTransaction::CHANGED, |
| 290 PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE), | 290 PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE), |
| 291 testing::Bool())); | 291 testing::Bool())); |
| OLD | NEW |