| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/pickle.h" | 5 #include "base/pickle.h" |
| 6 #include "components/nacl/browser/nacl_validation_cache.h" | 6 #include "components/nacl/browser/nacl_validation_cache.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace nacl { | 9 namespace nacl { |
| 10 | 10 |
| 11 const char key1[65] = | 11 const char key1[65] = |
| 12 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; | 12 "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF"; |
| 13 const char key2[65] = | 13 const char key2[65] = |
| 14 "a 64-byte string of various junk................................"; | 14 "a 64-byte string of various junk................................"; |
| 15 const char sig1[33] = "0123456789ABCDEF0123456789ABCDEF"; | 15 const char sig1[33] = "0123456789ABCDEF0123456789ABCDEF"; |
| 16 const char sig2[33] = "a 32-byte string of various junk"; | 16 const char sig2[33] = "a 32-byte string of various junk"; |
| 17 | 17 |
| 18 class NaClValidationCacheTest : public ::testing::Test { | 18 class NaClValidationCacheTest : public ::testing::Test { |
| 19 protected: | 19 protected: |
| 20 NaClValidationCache cache1; | 20 NaClValidationCache cache1; |
| 21 NaClValidationCache cache2; | 21 NaClValidationCache cache2; |
| 22 | 22 |
| 23 virtual void SetUp() { | 23 void SetUp() override { |
| 24 // The compiler chokes if std::string(key1) is passed directly as an arg. | 24 // The compiler chokes if std::string(key1) is passed directly as an arg. |
| 25 std::string key(key1); | 25 std::string key(key1); |
| 26 cache1.SetValidationCacheKey(key); | 26 cache1.SetValidationCacheKey(key); |
| 27 cache2.SetValidationCacheKey(key); | 27 cache2.SetValidationCacheKey(key); |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool IsIdentical(const NaClValidationCache& a, | 30 bool IsIdentical(const NaClValidationCache& a, |
| 31 const NaClValidationCache& b) const { | 31 const NaClValidationCache& b) const { |
| 32 if (a.GetValidationCacheKey() != b.GetValidationCacheKey()) | 32 if (a.GetValidationCacheKey() != b.GetValidationCacheKey()) |
| 33 return false; | 33 return false; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 TEST_F(NaClValidationCacheTest, DeserializeJunk) { | 186 TEST_F(NaClValidationCacheTest, DeserializeJunk) { |
| 187 cache1.SetKnownToValidate(sig1); | 187 cache1.SetKnownToValidate(sig1); |
| 188 Pickle pickle(key1, strlen(key1)); | 188 Pickle pickle(key1, strlen(key1)); |
| 189 ASSERT_FALSE(cache1.Deserialize(&pickle)); | 189 ASSERT_FALSE(cache1.Deserialize(&pickle)); |
| 190 ASSERT_EQ(0, (int) cache1.size()); | 190 ASSERT_EQ(0, (int) cache1.size()); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } | 193 } |
| OLD | NEW |