OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 testing::AssertionResult ExpectGetAccounts( | 372 testing::AssertionResult ExpectGetAccounts( |
373 const std::vector<std::string>& accounts) { | 373 const std::vector<std::string>& accounts) { |
374 scoped_refptr<IdentityGetAccountsFunction> func( | 374 scoped_refptr<IdentityGetAccountsFunction> func( |
375 new IdentityGetAccountsFunction); | 375 new IdentityGetAccountsFunction); |
376 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); | 376 func->set_extension(utils::CreateEmptyExtension(kExtensionId).get()); |
377 if (!utils::RunFunction( | 377 if (!utils::RunFunction( |
378 func.get(), std::string("[]"), browser(), utils::NONE)) { | 378 func.get(), std::string("[]"), browser(), utils::NONE)) { |
379 return GenerateFailureResult(accounts, NULL) | 379 return GenerateFailureResult(accounts, NULL) |
380 << "getAccounts did not return a result."; | 380 << "getAccounts did not return a result."; |
381 } | 381 } |
382 const base::ListValue* results = func->GetResultList(); | 382 const base::ListValue* callback_arguments = func->GetResultList(); |
383 if (!results || (results->GetSize() != accounts.size())) | 383 if (!callback_arguments) |
384 return GenerateFailureResult(accounts, results); | 384 return GenerateFailureResult(accounts, NULL) << "NULL result"; |
| 385 |
| 386 if (callback_arguments->GetSize() != 1) { |
| 387 return GenerateFailureResult(accounts, NULL) |
| 388 << "Expected 1 argument but got " << callback_arguments->GetSize(); |
| 389 } |
| 390 |
| 391 const base::ListValue* results; |
| 392 if (!callback_arguments->GetList(0, &results)) |
| 393 GenerateFailureResult(accounts, NULL) << "Result was not an array"; |
385 | 394 |
386 std::set<std::string> result_ids; | 395 std::set<std::string> result_ids; |
387 for (base::ListValue::const_iterator it = results->begin(); | 396 for (base::ListValue::const_iterator it = results->begin(); |
388 it != results->end(); | 397 it != results->end(); |
389 ++it) { | 398 ++it) { |
390 scoped_ptr<api::identity::AccountInfo> info = | 399 scoped_ptr<api::identity::AccountInfo> info = |
391 api::identity::AccountInfo::FromValue(**it); | 400 api::identity::AccountInfo::FromValue(**it); |
392 if (info.get()) | 401 if (info.get()) |
393 result_ids.insert(info->id); | 402 result_ids.insert(info->id); |
394 else | 403 else |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1473 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
1465 url); | 1474 url); |
1466 } | 1475 } |
1467 | 1476 |
1468 } // namespace extensions | 1477 } // namespace extensions |
1469 | 1478 |
1470 // Tests the chrome.identity API implemented by custom JS bindings . | 1479 // Tests the chrome.identity API implemented by custom JS bindings . |
1471 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1480 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
1472 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1481 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
1473 } | 1482 } |
OLD | NEW |