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

Side by Side Diff: chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api_unittest.cc

Issue 2740143002: Change base::Value::ListStorage to std::vector<base::Value> (Closed)
Patch Set: Rebase Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // This file tests the chromeos.quickUnlockPrivate extension API. 5 // This file tests the chromeos.quickUnlockPrivate extension API.
6 6
7 #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_p rivate_api.h" 7 #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_p rivate_api.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Run the function. 107 // Run the function.
108 std::unique_ptr<base::Value> result = 108 std::unique_ptr<base::Value> result =
109 RunFunction(new QuickUnlockPrivateGetAvailableModesFunction(), 109 RunFunction(new QuickUnlockPrivateGetAvailableModesFunction(),
110 base::MakeUnique<base::ListValue>()); 110 base::MakeUnique<base::ListValue>());
111 111
112 // Extract the results. 112 // Extract the results.
113 QuickUnlockModeList modes; 113 QuickUnlockModeList modes;
114 114
115 base::ListValue* list = nullptr; 115 base::ListValue* list = nullptr;
116 EXPECT_TRUE(result->GetAsList(&list)); 116 EXPECT_TRUE(result->GetAsList(&list));
117 // Consume the unique_ptr by reference so we don't take ownership. 117 for (const base::Value& value : *list) {
118 for (const std::unique_ptr<base::Value>& value : (*list)) {
119 std::string mode; 118 std::string mode;
120 EXPECT_TRUE(value->GetAsString(&mode)); 119 EXPECT_TRUE(value.GetAsString(&mode));
121 modes.push_back(quick_unlock_private::ParseQuickUnlockMode(mode)); 120 modes.push_back(quick_unlock_private::ParseQuickUnlockMode(mode));
122 } 121 }
123 122
124 return modes; 123 return modes;
125 } 124 }
126 125
127 // Wrapper for chrome.quickUnlockPrivate.getActiveModes. 126 // Wrapper for chrome.quickUnlockPrivate.getActiveModes.
128 QuickUnlockModeList GetActiveModes() { 127 QuickUnlockModeList GetActiveModes() {
129 std::unique_ptr<base::Value> result = 128 std::unique_ptr<base::Value> result =
130 RunFunction(new QuickUnlockPrivateGetActiveModesFunction(), 129 RunFunction(new QuickUnlockPrivateGetActiveModesFunction(),
131 base::MakeUnique<base::ListValue>()); 130 base::MakeUnique<base::ListValue>());
132 131
133 QuickUnlockModeList modes; 132 QuickUnlockModeList modes;
134 133
135 base::ListValue* list = nullptr; 134 base::ListValue* list = nullptr;
136 EXPECT_TRUE(result->GetAsList(&list)); 135 EXPECT_TRUE(result->GetAsList(&list));
137 for (const std::unique_ptr<base::Value>& value : *list) { 136 for (const base::Value& value : *list) {
138 std::string mode; 137 std::string mode;
139 EXPECT_TRUE(value->GetAsString(&mode)); 138 EXPECT_TRUE(value.GetAsString(&mode));
140 modes.push_back(quick_unlock_private::ParseQuickUnlockMode(mode)); 139 modes.push_back(quick_unlock_private::ParseQuickUnlockMode(mode));
141 } 140 }
142 141
143 return modes; 142 return modes;
144 } 143 }
145 144
146 // Returns true if |problem| is contained in |problems|. 145 // Returns true if |problem| is contained in |problems|.
147 bool HasProblem(CredentialProblem problem, 146 bool HasProblem(CredentialProblem problem,
148 const std::vector<CredentialProblem> problems) { 147 const std::vector<CredentialProblem> problems) {
149 return std::find(problems.begin(), problems.end(), problem) != 148 return std::find(problems.begin(), problems.end(), problem) !=
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // length pref. 484 // length pref.
486 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, 4); 485 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, 4);
487 CheckGetCredentialRequirements(6, 6); 486 CheckGetCredentialRequirements(6, 6);
488 487
489 // Verify that the values received from policy are sanitized. 488 // Verify that the values received from policy are sanitized.
490 pref_service->SetInteger(prefs::kPinUnlockMinimumLength, -3); 489 pref_service->SetInteger(prefs::kPinUnlockMinimumLength, -3);
491 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, -3); 490 pref_service->SetInteger(prefs::kPinUnlockMaximumLength, -3);
492 CheckGetCredentialRequirements(1, 0); 491 CheckGetCredentialRequirements(1, 0);
493 } 492 }
494 } // namespace chromeos 493 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698