Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: components/proximity_auth/proximity_auth_pref_manager_unittest.cc

Issue 2973243002: Adding pref to store the user-selected proximity threshold. (Closed)
Patch Set: Fixing browser tests Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 27 const int64_t kPasswordEntryTimestampMs1 = 123456789L;
28 const int64_t kPasswordEntryTimestampMs2 = 987654321L; 28 const int64_t kPasswordEntryTimestampMs2 = 987654321L;
29 29
30 const ProximityAuthPrefManager::ProximityThreshold kProximityThreshold1 =
31 ProximityAuthPrefManager::ProximityThreshold::kFar;
32 const ProximityAuthPrefManager::ProximityThreshold kProximityThreshold2 =
33 ProximityAuthPrefManager::ProximityThreshold::kVeryFar;
34
30 } // namespace 35 } // namespace
31 36
32 class ProximityAuthProximityAuthPrefManagerTest : public testing::Test { 37 class ProximityAuthProximityAuthPrefManagerTest : public testing::Test {
33 protected: 38 protected:
34 ProximityAuthProximityAuthPrefManagerTest() {} 39 ProximityAuthProximityAuthPrefManagerTest() {}
35 40
36 void SetUp() override { 41 void SetUp() override {
37 ProximityAuthPrefManager::RegisterPrefs(pref_service_.registry()); 42 ProximityAuthPrefManager::RegisterPrefs(pref_service_.registry());
38 } 43 }
39 44
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ProximityAuthPrefManager pref_manager(&pref_service_); 168 ProximityAuthPrefManager pref_manager(&pref_service_);
164 EXPECT_EQ(0L, pref_manager.GetLastPasswordEntryTimestampMs()); 169 EXPECT_EQ(0L, pref_manager.GetLastPasswordEntryTimestampMs());
165 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs1); 170 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs1);
166 EXPECT_EQ(kPasswordEntryTimestampMs1, 171 EXPECT_EQ(kPasswordEntryTimestampMs1,
167 pref_manager.GetLastPasswordEntryTimestampMs()); 172 pref_manager.GetLastPasswordEntryTimestampMs());
168 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs2); 173 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs2);
169 EXPECT_EQ(kPasswordEntryTimestampMs2, 174 EXPECT_EQ(kPasswordEntryTimestampMs2,
170 pref_manager.GetLastPasswordEntryTimestampMs()); 175 pref_manager.GetLastPasswordEntryTimestampMs());
171 } 176 }
172 177
178 TEST_F(ProximityAuthProximityAuthPrefManagerTest, ProximityThreshold) {
179 ProximityAuthPrefManager pref_manager(&pref_service_);
180 EXPECT_EQ(1, pref_manager.GetProximityThreshold());
181 pref_manager.SetProximityThreshold(kProximityThreshold1);
182 EXPECT_EQ(kProximityThreshold1, pref_manager.GetProximityThreshold());
183 pref_manager.SetProximityThreshold(kProximityThreshold2);
184 EXPECT_EQ(kProximityThreshold2, pref_manager.GetProximityThreshold());
185 }
186
173 } // namespace proximity_auth 187 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698