| 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 "chrome/browser/ui/webui/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 DISALLOW_COPY_AND_ASSIGN(TestingSyncSetupHandler); | 320 DISALLOW_COPY_AND_ASSIGN(TestingSyncSetupHandler); |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 class SigninManagerBaseMock : public FakeSigninManagerBase { | 323 class SigninManagerBaseMock : public FakeSigninManagerBase { |
| 324 public: | 324 public: |
| 325 explicit SigninManagerBaseMock(Profile* profile) | 325 explicit SigninManagerBaseMock(Profile* profile) |
| 326 : FakeSigninManagerBase(profile) {} | 326 : FakeSigninManagerBase(profile) {} |
| 327 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); | 327 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 static ProfileKeyedService* BuildSigninManagerBaseMock(Profile* profile) { | 330 static ProfileKeyedService* BuildSigninManagerBaseMock( |
| 331 return new SigninManagerBaseMock(profile); | 331 content::BrowserContext* profile) { |
| 332 return new SigninManagerBaseMock(static_cast<Profile*>(profile)); |
| 332 } | 333 } |
| 333 | 334 |
| 334 // The boolean parameter indicates whether the test is run with ClientOAuth | 335 // The boolean parameter indicates whether the test is run with ClientOAuth |
| 335 // or not. The test parameter is a bool: whether or not to test with/ | 336 // or not. The test parameter is a bool: whether or not to test with/ |
| 336 // /ClientLogin enabled or not. | 337 // /ClientLogin enabled or not. |
| 337 class SyncSetupHandlerTest : public testing::TestWithParam<bool> { | 338 class SyncSetupHandlerTest : public testing::TestWithParam<bool> { |
| 338 public: | 339 public: |
| 339 SyncSetupHandlerTest() : error_(GoogleServiceAuthError::NONE) {} | 340 SyncSetupHandlerTest() : error_(GoogleServiceAuthError::NONE) {} |
| 340 virtual void SetUp() OVERRIDE { | 341 virtual void SetUp() OVERRIDE { |
| 341 bool use_client_login_flow = GetParam(); | 342 bool use_client_login_flow = GetParam(); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 const std::string& password, | 678 const std::string& password, |
| 678 const std::string& login_token, | 679 const std::string& login_token, |
| 679 const std::string& login_captcha) OVERRIDE { | 680 const std::string& login_captcha) OVERRIDE { |
| 680 SetAuthenticatedUsername(username); | 681 SetAuthenticatedUsername(username); |
| 681 } | 682 } |
| 682 | 683 |
| 683 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); | 684 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); |
| 684 }; | 685 }; |
| 685 } | 686 } |
| 686 | 687 |
| 687 static ProfileKeyedService* BuildSigninManagerMock(Profile* profile) { | 688 static ProfileKeyedService* BuildSigninManagerMock( |
| 688 return new SigninManagerMock(profile); | 689 content::BrowserContext* profile) { |
| 690 return new SigninManagerMock(static_cast<Profile*>(profile)); |
| 689 } | 691 } |
| 690 | 692 |
| 691 class SyncSetupHandlerNonCrosTest : public SyncSetupHandlerTest { | 693 class SyncSetupHandlerNonCrosTest : public SyncSetupHandlerTest { |
| 692 public: | 694 public: |
| 693 SyncSetupHandlerNonCrosTest() {} | 695 SyncSetupHandlerNonCrosTest() {} |
| 694 virtual void SetUp() OVERRIDE { | 696 virtual void SetUp() OVERRIDE { |
| 695 SyncSetupHandlerTest::SetUp(); | 697 SyncSetupHandlerTest::SetUp(); |
| 696 mock_signin_ = static_cast<SigninManagerMock*>( | 698 mock_signin_ = static_cast<SigninManagerMock*>( |
| 697 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 699 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
| 698 profile_.get(), BuildSigninManagerMock)); | 700 profile_.get(), BuildSigninManagerMock)); |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 ExpectConfig(); | 1338 ExpectConfig(); |
| 1337 const TestWebUI::CallData& data = web_ui_.call_data()[0]; | 1339 const TestWebUI::CallData& data = web_ui_.call_data()[0]; |
| 1338 DictionaryValue* dictionary; | 1340 DictionaryValue* dictionary; |
| 1339 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); | 1341 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); |
| 1340 CheckBool(dictionary, "encryptAllData", true); | 1342 CheckBool(dictionary, "encryptAllData", true); |
| 1341 } | 1343 } |
| 1342 | 1344 |
| 1343 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, | 1345 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, |
| 1344 SyncSetupHandlerTest, | 1346 SyncSetupHandlerTest, |
| 1345 Values(true, false)); | 1347 Values(true, false)); |
| OLD | NEW |