| 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/proximity_auth/proximity_auth_pref_manager.h" | 5 #include "components/proximity_auth/proximity_auth_pref_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/prefs/testing_pref_service.h" | 13 #include "components/prefs/testing_pref_service.h" |
| 14 #include "components/proximity_auth/proximity_auth_pref_names.h" | 14 #include "components/proximity_auth/proximity_auth_pref_names.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace proximity_auth { | 18 namespace proximity_auth { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const char kBluetoothAddress1[] = "11:22:33:44:55:66"; | 21 const char kBluetoothAddress1[] = "11:22:33:44:55:66"; |
| 22 const char kPublicKey1[] = "public key 1"; | 22 const char kPublicKey1[] = "public key 1"; |
| 23 | 23 |
| 24 const char kBluetoothAddress2[] = "22:33:44:55:66:77"; | 24 const char kBluetoothAddress2[] = "22:33:44:55:66:77"; |
| 25 const char kPublicKey2[] = "public key 2"; | 25 const char kPublicKey2[] = "public key 2"; |
| 26 | 26 |
| 27 const int64_t kPasswordEntryTimestampMs1 = 123456789L; |
| 28 const int64_t kPasswordEntryTimestampMs2 = 987654321L; |
| 29 |
| 27 } // namespace | 30 } // namespace |
| 28 | 31 |
| 29 class ProximityAuthProximityAuthPrefManagerTest : public testing::Test { | 32 class ProximityAuthProximityAuthPrefManagerTest : public testing::Test { |
| 30 protected: | 33 protected: |
| 31 ProximityAuthProximityAuthPrefManagerTest() {} | 34 ProximityAuthProximityAuthPrefManagerTest() {} |
| 32 | 35 |
| 33 void SetUp() override { | 36 void SetUp() override { |
| 34 ProximityAuthPrefManager::RegisterPrefs(pref_service_.registry()); | 37 ProximityAuthPrefManager::RegisterPrefs(pref_service_.registry()); |
| 35 } | 38 } |
| 36 | 39 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 152 |
| 150 // Note: it's not guarantee that the order in |public_key| is the same as | 153 // Note: it's not guarantee that the order in |public_key| is the same as |
| 151 // insertion, so directly comparing vectors would not work. | 154 // insertion, so directly comparing vectors would not work. |
| 152 EXPECT_TRUE(public_keys.size() == 2); | 155 EXPECT_TRUE(public_keys.size() == 2); |
| 153 EXPECT_TRUE(std::find(public_keys.begin(), public_keys.end(), kPublicKey1) != | 156 EXPECT_TRUE(std::find(public_keys.begin(), public_keys.end(), kPublicKey1) != |
| 154 public_keys.end()); | 157 public_keys.end()); |
| 155 EXPECT_TRUE(std::find(public_keys.begin(), public_keys.end(), kPublicKey2) != | 158 EXPECT_TRUE(std::find(public_keys.begin(), public_keys.end(), kPublicKey2) != |
| 156 public_keys.end()); | 159 public_keys.end()); |
| 157 } | 160 } |
| 158 | 161 |
| 162 TEST_F(ProximityAuthProximityAuthPrefManagerTest, LastPasswordEntryTimestamp) { |
| 163 ProximityAuthPrefManager pref_manager(&pref_service_); |
| 164 EXPECT_EQ(0L, pref_manager.GetLastPasswordEntryTimestampMs()); |
| 165 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs1); |
| 166 EXPECT_EQ(kPasswordEntryTimestampMs1, |
| 167 pref_manager.GetLastPasswordEntryTimestampMs()); |
| 168 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs2); |
| 169 EXPECT_EQ(kPasswordEntryTimestampMs2, |
| 170 pref_manager.GetLastPasswordEntryTimestampMs()); |
| 171 } |
| 172 |
| 159 } // namespace proximity_auth | 173 } // namespace proximity_auth |
| OLD | NEW |