| 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 "components/gcm_driver/instance_id/instance_id_driver.h" | 5 #include "components/gcm_driver/instance_id/instance_id_driver.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const char kScope2[] = "FooBar"; | 25 const char kScope2[] = "FooBar"; |
| 26 | 26 |
| 27 bool VerifyInstanceID(const std::string& str) { | 27 bool VerifyInstanceID(const std::string& str) { |
| 28 // Checks the length. | 28 // Checks the length. |
| 29 if (str.length() != static_cast<size_t>( | 29 if (str.length() != static_cast<size_t>( |
| 30 std::ceil(InstanceID::kInstanceIDByteLength * 8 / 6.0))) | 30 std::ceil(InstanceID::kInstanceIDByteLength * 8 / 6.0))) |
| 31 return false; | 31 return false; |
| 32 | 32 |
| 33 // Checks if it is URL-safe base64 encoded. | 33 // Checks if it is URL-safe base64 encoded. |
| 34 for (auto ch : str) { | 34 for (auto ch : str) { |
| 35 if (!IsAsciiAlpha(ch) && !IsAsciiDigit(ch) && ch != '_' && ch != '-') | 35 if (!base::IsAsciiAlpha(ch) && !base::IsAsciiDigit(ch) && |
| 36 ch != '_' && ch != '-') |
| 36 return false; | 37 return false; |
| 37 } | 38 } |
| 38 return true; | 39 return true; |
| 39 } | 40 } |
| 40 | 41 |
| 41 } // namespace | 42 } // namespace |
| 42 | 43 |
| 43 class InstanceIDDriverTest : public testing::Test { | 44 class InstanceIDDriverTest : public testing::Test { |
| 44 public: | 45 public: |
| 45 InstanceIDDriverTest(); | 46 InstanceIDDriverTest(); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 GetToken(instance_id, kAuthorizedEntity1, kScope2, options); | 347 GetToken(instance_id, kAuthorizedEntity1, kScope2, options); |
| 347 EXPECT_FALSE(new_token1.empty()); | 348 EXPECT_FALSE(new_token1.empty()); |
| 348 EXPECT_NE(token1, new_token1); | 349 EXPECT_NE(token1, new_token1); |
| 349 | 350 |
| 350 // The other token is not affected by the deletion. | 351 // The other token is not affected by the deletion. |
| 351 EXPECT_EQ(token2, | 352 EXPECT_EQ(token2, |
| 352 GetToken(instance_id, kAuthorizedEntity2, kScope1, options)); | 353 GetToken(instance_id, kAuthorizedEntity2, kScope1, options)); |
| 353 } | 354 } |
| 354 | 355 |
| 355 } // instance_id | 356 } // instance_id |
| OLD | NEW |