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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler_unittest.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 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 #include "chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler .h" 5 #include "chrome/browser/ui/webui/settings/chromeos/easy_unlock_settings_handler .h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "chrome/browser/signin/easy_unlock_service.h" 10 #include "chrome/browser/signin/easy_unlock_service.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 EXPECT_FALSE(handler.get()); 191 EXPECT_FALSE(handler.get());
192 } 192 }
193 193
194 TEST_F(EasyUnlockSettingsHandlerTest, EnabledStatus) { 194 TEST_F(EasyUnlockSettingsHandlerTest, EnabledStatus) {
195 std::unique_ptr<EasyUnlockSettingsHandler> handler; 195 std::unique_ptr<EasyUnlockSettingsHandler> handler;
196 handler.reset(new TestEasyUnlockSettingsHandler(profile())); 196 handler.reset(new TestEasyUnlockSettingsHandler(profile()));
197 handler->set_web_ui(web_ui()); 197 handler->set_web_ui(web_ui());
198 198
199 // Test the JS -> C++ -> JS callback path. 199 // Test the JS -> C++ -> JS callback path.
200 base::ListValue list_args; 200 base::ListValue list_args;
201 list_args.Append(new base::StringValue("test-callback-id")); 201 list_args.AppendString("test-callback-id");
202 handler->HandleGetEnabledStatus(&list_args); 202 handler->HandleGetEnabledStatus(&list_args);
203 203
204 EXPECT_EQ(1U, web_ui()->call_data().size()); 204 EXPECT_EQ(1U, web_ui()->call_data().size());
205 205
206 const content::TestWebUI::CallData& data = *web_ui()->call_data().back(); 206 const content::TestWebUI::CallData& data = *web_ui()->call_data().back();
207 EXPECT_EQ("cr.webUIResponse", data.function_name()); 207 EXPECT_EQ("cr.webUIResponse", data.function_name());
208 208
209 std::string callback_id; 209 std::string callback_id;
210 ASSERT_TRUE(data.arg1()->GetAsString(&callback_id)); 210 ASSERT_TRUE(data.arg1()->GetAsString(&callback_id));
211 EXPECT_EQ("test-callback-id", callback_id); 211 EXPECT_EQ("test-callback-id", callback_id);
(...skipping 11 matching lines...) Expand all
223 VerifyEnabledStatusCallback(3U, true); 223 VerifyEnabledStatusCallback(3U, true);
224 } 224 }
225 225
226 TEST_F(EasyUnlockSettingsHandlerTest, TurnOffFlowStatus) { 226 TEST_F(EasyUnlockSettingsHandlerTest, TurnOffFlowStatus) {
227 std::unique_ptr<EasyUnlockSettingsHandler> handler; 227 std::unique_ptr<EasyUnlockSettingsHandler> handler;
228 handler.reset(new TestEasyUnlockSettingsHandler(profile())); 228 handler.reset(new TestEasyUnlockSettingsHandler(profile()));
229 handler->set_web_ui(web_ui()); 229 handler->set_web_ui(web_ui());
230 230
231 // Send an initial status query to turn on service observer. 231 // Send an initial status query to turn on service observer.
232 base::ListValue list_args1; 232 base::ListValue list_args1;
233 list_args1.Append(new base::StringValue("test-callback-id-1")); 233 list_args1.AppendString("test-callback-id-1");
234 handler->HandleGetEnabledStatus(&list_args1); 234 handler->HandleGetEnabledStatus(&list_args1);
235 EXPECT_EQ(1U, web_ui()->call_data().size()); 235 EXPECT_EQ(1U, web_ui()->call_data().size());
236 236
237 base::ListValue list_args2; 237 base::ListValue list_args2;
238 list_args2.Append(new base::StringValue("test-callback-id-2")); 238 list_args2.AppendString("test-callback-id-2");
239 handler->HandleGetTurnOffFlowStatus(&list_args2); 239 handler->HandleGetTurnOffFlowStatus(&list_args2);
240 VerifyTurnOffFlowStatusWebUIResponse(2U, "test-callback-id-2", "idle"); 240 VerifyTurnOffFlowStatusWebUIResponse(2U, "test-callback-id-2", "idle");
241 241
242 handler->HandleStartTurnOffFlow(nullptr); 242 handler->HandleStartTurnOffFlow(nullptr);
243 VerifyTurnOffFlowStatusWebUIListenerCallback(3U, "pending"); 243 VerifyTurnOffFlowStatusWebUIListenerCallback(3U, "pending");
244 244
245 base::ListValue list_args3; 245 base::ListValue list_args3;
246 list_args3.Append(new base::StringValue("test-callback-id-3")); 246 list_args3.AppendString("test-callback-id-3");
247 handler->HandleGetTurnOffFlowStatus(&list_args3); 247 handler->HandleGetTurnOffFlowStatus(&list_args3);
248 VerifyTurnOffFlowStatusWebUIResponse(4U, "test-callback-id-3", "pending"); 248 VerifyTurnOffFlowStatusWebUIResponse(4U, "test-callback-id-3", "pending");
249 249
250 handler->HandleCancelTurnOffFlow(nullptr); 250 handler->HandleCancelTurnOffFlow(nullptr);
251 VerifyTurnOffFlowStatusWebUIListenerCallback(5U, "idle"); 251 VerifyTurnOffFlowStatusWebUIListenerCallback(5U, "idle");
252 252
253 fake_easy_unlock_service()->SetTurnOffFlowFailForTest(); 253 fake_easy_unlock_service()->SetTurnOffFlowFailForTest();
254 VerifyTurnOffFlowStatusWebUIListenerCallback(6U, "server-error"); 254 VerifyTurnOffFlowStatusWebUIListenerCallback(6U, "server-error");
255 255
256 base::ListValue list_args4; 256 base::ListValue list_args4;
257 list_args4.Append(new base::StringValue("test-callback-id-4")); 257 list_args4.AppendString("test-callback-id-4");
258 handler->HandleGetTurnOffFlowStatus(&list_args4); 258 handler->HandleGetTurnOffFlowStatus(&list_args4);
259 VerifyTurnOffFlowStatusWebUIResponse(7U, "test-callback-id-4", 259 VerifyTurnOffFlowStatusWebUIResponse(7U, "test-callback-id-4",
260 "server-error"); 260 "server-error");
261 } 261 }
262 262
263 } // namespace settings 263 } // namespace settings
264 } // namespace chromeos 264 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/chromeos/change_picture_handler.cc ('k') | chrome/browser/ui/webui/voice_search_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698