Chromium Code Reviews| Index: chrome/browser/safe_browsing/incident_reporting/variations_seed_signature_incident_handlers_unittest.cc |
| diff --git a/chrome/browser/safe_browsing/incident_reporting/variations_seed_signature_incident_handlers_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/variations_seed_signature_incident_handlers_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5868854c7b80c0613bd38833a3065d5ef32b16c4 |
| --- /dev/null |
| +++ b/chrome/browser/safe_browsing/incident_reporting/variations_seed_signature_incident_handlers_unittest.cc |
| @@ -0,0 +1,63 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/safe_browsing/incident_reporting/variations_seed_signature_incident_handlers.h" |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/common/safe_browsing/csd.pb.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +namespace safe_browsing { |
| + |
| +scoped_ptr<ClientIncidentReport_IncidentData> MakeIncident() { |
| + scoped_ptr<ClientIncidentReport_IncidentData> incident( |
| + new ClientIncidentReport_IncidentData); |
| + incident->mutable_variations_seed_signature()->set_variations_seed_signature( |
| + "MEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + return incident.Pass(); |
| +} |
| + |
| +// Tests that GetKey returns a constant. |
| +TEST(GetVariationsSeedSignatureIncidentKey, KeyIsConstant) { |
| + ClientIncidentReport_IncidentData incident; |
| + |
| + incident.mutable_variations_seed_signature()->set_variations_seed_signature( |
| + "MEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + ASSERT_EQ(std::string("variations_seed_signature"), |
| + GetVariationsSeedSignatureIncidentKey(incident)); |
| + incident.mutable_variations_seed_signature()->set_variations_seed_signature( |
| + "AEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + ASSERT_EQ(std::string("variations_seed_signature"), |
|
Alexei Svitkine (slow)
2014/10/14 18:15:06
Nit: Do you need the std::string() wrapper? I beli
Georges Khalil
2014/10/15 14:41:47
Done.
|
| + GetVariationsSeedSignatureIncidentKey(incident)); |
| +} |
| + |
| +// Tests that GetDigest returns the same value for the same incident. |
| +TEST(GetVariationsSeedSignatureIncidentDigest, SameIncidentSameDigest) { |
| + scoped_ptr<ClientIncidentReport_IncidentData> incident(MakeIncident()); |
| + |
| + uint32_t digest = GetVariationsSeedSignatureIncidentDigest(*incident); |
| + ASSERT_EQ(digest, GetVariationsSeedSignatureIncidentDigest(*MakeIncident())); |
| +} |
| + |
| +// Tests that GetDigest returns different values for different incidents. |
| +TEST(GetVariationsSeedSignatureIncidentDigest, |
| + DifferentIncidentDifferentDigest) { |
| + scoped_ptr<ClientIncidentReport_IncidentData> incident(MakeIncident()); |
| + incident->mutable_variations_seed_signature()->set_variations_seed_signature( |
| + "MEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + |
| + scoped_ptr<ClientIncidentReport_IncidentData> incident2(MakeIncident()); |
| + incident2->mutable_variations_seed_signature()->set_variations_seed_signature( |
| + "AEUCID+QmAfajh/kk4zZyv0IUisZ84sIddnjiW9yAXjFJIMFAiEAtVUHhFA/4M6Bff2GazL" |
| + "7tXVLhURxUQcpiMg9eMLWO0U="); |
| + |
| + ASSERT_NE(GetVariationsSeedSignatureIncidentDigest(*incident), |
|
Alexei Svitkine (slow)
2014/10/14 18:15:06
Nit: You should use EXPECT_NE. ASSERT_* macros sho
Georges Khalil
2014/10/15 14:41:47
Done.
|
| + GetVariationsSeedSignatureIncidentDigest(*incident2)); |
| +} |
| + |
| +} // namespace safe_browsing |