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

Side by Side Diff: chrome/browser/ui/webui/sync_setup_handler_unittest.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 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 (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"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/signin/fake_auth_status_provider.h" 16 #include "chrome/browser/signin/fake_auth_status_provider.h"
17 #include "chrome/browser/signin/fake_signin_manager.h" 17 #include "chrome/browser/signin/fake_signin_manager.h"
18 #include "chrome/browser/signin/signin_manager.h" 18 #include "chrome/browser/signin/signin_manager.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 20 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/sync/profile_sync_service_mock.h" 21 #include "chrome/browser/sync/profile_sync_service_mock.h"
22 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 22 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 23 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
24 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 24 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/test/base/testing_profile.h" 27 #include "chrome/test/base/testing_profile.h"
28 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
29 #include "content/public/test/test_browser_thread.h"
29 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/layout.h" 33 #include "ui/base/layout.h"
33 34
34 using ::testing::_; 35 using ::testing::_;
35 using ::testing::Mock; 36 using ::testing::Mock;
36 using ::testing::Return; 37 using ::testing::Return;
37 using ::testing::ReturnRef; 38 using ::testing::ReturnRef;
38 using ::testing::Values; 39 using ::testing::Values;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 static ProfileKeyedService* BuildSigninManagerBaseMock( 331 static ProfileKeyedService* BuildSigninManagerBaseMock(
331 content::BrowserContext* profile) { 332 content::BrowserContext* profile) {
332 return new SigninManagerBaseMock(static_cast<Profile*>(profile)); 333 return new SigninManagerBaseMock(static_cast<Profile*>(profile));
333 } 334 }
334 335
335 // The boolean parameter indicates whether the test is run with ClientOAuth 336 // The boolean parameter indicates whether the test is run with ClientOAuth
336 // or not. The test parameter is a bool: whether or not to test with/ 337 // or not. The test parameter is a bool: whether or not to test with/
337 // /ClientLogin enabled or not. 338 // /ClientLogin enabled or not.
338 class SyncSetupHandlerTest : public testing::TestWithParam<bool> { 339 class SyncSetupHandlerTest : public testing::TestWithParam<bool> {
339 public: 340 public:
340 SyncSetupHandlerTest() : error_(GoogleServiceAuthError::NONE) {} 341 SyncSetupHandlerTest() :
342 error_(GoogleServiceAuthError::NONE),
tim (not reviewing) 2013/05/23 19:03:42 indent is off (4 spaces)
pavely 2013/05/30 07:42:12 Done.
343 ui_thread_(content::BrowserThread::UI, &message_loop_) {}
341 virtual void SetUp() OVERRIDE { 344 virtual void SetUp() OVERRIDE {
342 bool use_client_login_flow = GetParam(); 345 bool use_client_login_flow = GetParam();
343 if (use_client_login_flow) { 346 if (use_client_login_flow) {
344 if (!CommandLine::ForCurrentProcess()->HasSwitch( 347 if (!CommandLine::ForCurrentProcess()->HasSwitch(
345 switches::kUseClientLoginSigninFlow)) { 348 switches::kUseClientLoginSigninFlow)) {
346 CommandLine::ForCurrentProcess()->AppendSwitch( 349 CommandLine::ForCurrentProcess()->AppendSwitch(
347 switches::kUseClientLoginSigninFlow); 350 switches::kUseClientLoginSigninFlow);
348 } 351 }
349 } else { 352 } else {
350 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch( 353 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 409
407 void ExpectDone() { 410 void ExpectDone() {
408 ASSERT_EQ(1U, web_ui_.call_data().size()); 411 ASSERT_EQ(1U, web_ui_.call_data().size());
409 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 412 const TestWebUI::CallData& data = web_ui_.call_data()[0];
410 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name); 413 EXPECT_EQ("SyncSetupOverlay.showSyncSetupPage", data.function_name);
411 std::string page; 414 std::string page;
412 ASSERT_TRUE(data.arg1->GetAsString(&page)); 415 ASSERT_TRUE(data.arg1->GetAsString(&page));
413 EXPECT_EQ(page, "done"); 416 EXPECT_EQ(page, "done");
414 } 417 }
415 418
419 GoogleServiceAuthError error_;
420 MessageLoop message_loop_;
421 content::TestBrowserThread ui_thread_;
416 scoped_ptr<Profile> profile_; 422 scoped_ptr<Profile> profile_;
417 ProfileSyncServiceMock* mock_pss_; 423 ProfileSyncServiceMock* mock_pss_;
418 GoogleServiceAuthError error_;
419 // MessageLoop instance is required to work with OneShotTimer. 424 // MessageLoop instance is required to work with OneShotTimer.
Andrew T Wilson (Slow) 2013/05/24 14:10:15 Is this comment now obsolete?
420 MessageLoop message_loop_;
421 SigninManagerBase* mock_signin_; 425 SigninManagerBase* mock_signin_;
422 TestWebUI web_ui_; 426 TestWebUI web_ui_;
423 scoped_ptr<TestingSyncSetupHandler> handler_; 427 scoped_ptr<TestingSyncSetupHandler> handler_;
424 }; 428 };
425 429
426 TEST_P(SyncSetupHandlerTest, Basic) { 430 TEST_P(SyncSetupHandlerTest, Basic) {
427 } 431 }
428 432
429 TEST_P(SyncSetupHandlerTest, DisplayBasicLogin) { 433 TEST_P(SyncSetupHandlerTest, DisplayBasicLogin) {
430 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) 434 EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 ExpectConfig(); 1326 ExpectConfig();
1323 const TestWebUI::CallData& data = web_ui_.call_data()[0]; 1327 const TestWebUI::CallData& data = web_ui_.call_data()[0];
1324 DictionaryValue* dictionary; 1328 DictionaryValue* dictionary;
1325 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary)); 1329 ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
1326 CheckBool(dictionary, "encryptAllData", true); 1330 CheckBool(dictionary, "encryptAllData", true);
1327 } 1331 }
1328 1332
1329 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam, 1333 INSTANTIATE_TEST_CASE_P(SyncSetupHandlerTestWithParam,
1330 SyncSetupHandlerTest, 1334 SyncSetupHandlerTest,
1331 Values(true, false)); 1335 Values(true, false));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698