| Index: chrome/browser/extensions/api/identity/identity_apitest.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/api/identity/identity_apitest.cc (revision 146190)
|
| +++ chrome/browser/extensions/api/identity/identity_apitest.cc (working copy)
|
| @@ -2,14 +2,24 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/values.h"
|
| #include "chrome/browser/extensions/api/identity/identity_api.h"
|
| #include "chrome/browser/extensions/api/identity/web_auth_flow.h"
|
| #include "chrome/browser/extensions/extension_apitest.h"
|
| +#include "chrome/browser/extensions/extension_function_test_utils.h"
|
| +#include "chrome/browser/ui/webui/signin/login_ui_service.h"
|
| #include "chrome/common/net/gaia/google_service_auth_error.h"
|
| #include "chrome/common/net/gaia/oauth2_mint_token_flow.h"
|
| #include "chrome/common/chrome_switches.h"
|
| +#include "chrome/test/base/in_process_browser_test.h"
|
| #include "googleurl/src/gurl.h"
|
| +#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
|
|
| +using testing::ReturnRef;
|
| +
|
| +namespace utils = extension_function_test_utils;
|
| +
|
| namespace {
|
|
|
| class IdentityInterceptor : public OAuth2MintTokenFlow::InterceptorForTests {
|
| @@ -46,6 +56,16 @@
|
| bool called_;
|
| };
|
|
|
| +class MockGetAuthTokenFunction : public extensions::GetAuthTokenFunction {
|
| + public:
|
| + void ShowLoginPopup() {
|
| + // Do nothing in tests.
|
| + }
|
| + MOCK_CONST_METHOD0(HasLoginToken, bool ());
|
| + MOCK_CONST_METHOD0(GetOAuth2Info,
|
| + const extensions::Extension::OAuth2Info& ());
|
| +};
|
| +
|
| } // namespace
|
|
|
| IN_PROC_BROWSER_TEST_F(PlatformAppApiTest, Identity) {
|
| @@ -57,3 +77,17 @@
|
| ASSERT_TRUE(id_interceptor.called());
|
| ASSERT_TRUE(waf_interceptor.called());
|
| };
|
| +
|
| +IN_PROC_BROWSER_TEST_F(PlatformAppApiTest, GetAuthToken) {
|
| + scoped_refptr<MockGetAuthTokenFunction> func(new MockGetAuthTokenFunction());
|
| + extensions::Extension::OAuth2Info oauth2_info;
|
| + ON_CALL(*func.get(), GetOAuth2Info()).WillByDefault(ReturnRef(oauth2_info));
|
| + // Without a callback the function will not generate a result.
|
| + func->set_has_callback(true);
|
| + std::string error = utils::RunFunctionAndReturnError(
|
| + func.get(), "[]", browser());
|
| + // scoped_ptr<base::Value> result(utils::RunFunctionAndReturnResult(
|
| + // func.get(), "{}", browser()));
|
| +}
|
| +
|
| +
|
|
|