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

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 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 int kProximityThreshold1 = 2;
31 const int kProximityThreshold2 = 3;
32
30 } // namespace 33 } // namespace
31 34
32 class ProximityAuthProximityAuthPrefManagerTest : public testing::Test { 35 class ProximityAuthProximityAuthPrefManagerTest : public testing::Test {
33 protected: 36 protected:
34 ProximityAuthProximityAuthPrefManagerTest() {} 37 ProximityAuthProximityAuthPrefManagerTest() {}
35 38
36 void SetUp() override { 39 void SetUp() override {
37 ProximityAuthPrefManager::RegisterPrefs(pref_service_.registry()); 40 ProximityAuthPrefManager::RegisterPrefs(pref_service_.registry());
38 } 41 }
39 42
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ProximityAuthPrefManager pref_manager(&pref_service_); 166 ProximityAuthPrefManager pref_manager(&pref_service_);
164 EXPECT_EQ(0L, pref_manager.GetLastPasswordEntryTimestampMs()); 167 EXPECT_EQ(0L, pref_manager.GetLastPasswordEntryTimestampMs());
165 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs1); 168 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs1);
166 EXPECT_EQ(kPasswordEntryTimestampMs1, 169 EXPECT_EQ(kPasswordEntryTimestampMs1,
167 pref_manager.GetLastPasswordEntryTimestampMs()); 170 pref_manager.GetLastPasswordEntryTimestampMs());
168 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs2); 171 pref_manager.SetLastPasswordEntryTimestampMs(kPasswordEntryTimestampMs2);
169 EXPECT_EQ(kPasswordEntryTimestampMs2, 172 EXPECT_EQ(kPasswordEntryTimestampMs2,
170 pref_manager.GetLastPasswordEntryTimestampMs()); 173 pref_manager.GetLastPasswordEntryTimestampMs());
171 } 174 }
172 175
176 TEST_F(ProximityAuthProximityAuthPrefManagerTest, ProximityThreshold) {
177 ProximityAuthPrefManager pref_manager(&pref_service_);
178 EXPECT_EQ(1, pref_manager.GetProximityThreshold());
179 pref_manager.SetProximityThreshold(kProximityThreshold1);
180 EXPECT_EQ(kProximityThreshold1, pref_manager.GetProximityThreshold());
181 pref_manager.SetProximityThreshold(kProximityThreshold2);
182 EXPECT_EQ(kProximityThreshold2, pref_manager.GetProximityThreshold());
183 }
184
173 } // namespace proximity_auth 185 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698