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

Side by Side Diff: chrome/browser/chromeos/login/google_authenticator_unittest.cc

Issue 3077006: Fix nit for oshima (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // canceled, and fails the test if it is not 54 // canceled, and fails the test if it is not
55 class ExpectCanceledFetcher : public URLFetcher { 55 class ExpectCanceledFetcher : public URLFetcher {
56 public: 56 public:
57 ExpectCanceledFetcher(bool success, 57 ExpectCanceledFetcher(bool success,
58 const GURL& url, 58 const GURL& url,
59 URLFetcher::RequestType request_type, 59 URLFetcher::RequestType request_type,
60 URLFetcher::Delegate* d) 60 URLFetcher::Delegate* d)
61 : URLFetcher(url, request_type, d) { 61 : URLFetcher(url, request_type, d) {
62 } 62 }
63 63
64 ~ExpectCanceledFetcher() { 64 virtual ~ExpectCanceledFetcher() {
65 task_->Cancel(); 65 task_->Cancel();
66 } 66 }
67 67
68 static void CompleteFetch() { 68 static void CompleteFetch() {
69 ADD_FAILURE() << "Fetch completed in ExpectCanceledFetcher!"; 69 ADD_FAILURE() << "Fetch completed in ExpectCanceledFetcher!";
70 MessageLoop::current()->Quit(); // Allow exiting even if we mess up. 70 MessageLoop::current()->Quit(); // Allow exiting even if we mess up.
71 } 71 }
72 72
73 void Start() { 73 void Start() {
74 LOG(INFO) << "Delaying fetch completion in mock"; 74 LOG(INFO) << "Delaying fetch completion in mock";
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 .WillOnce(Return(true)) 511 .WillOnce(Return(true))
512 .RetiresOnSaturation(); 512 .RetiresOnSaturation();
513 513
514 scoped_refptr<GoogleAuthenticator> auth(new GoogleAuthenticator(&consumer)); 514 scoped_refptr<GoogleAuthenticator> auth(new GoogleAuthenticator(&consumer));
515 PrepForLogin(auth.get()); 515 PrepForLogin(auth.get());
516 auth->SetLocalaccount(username_); 516 auth->SetLocalaccount(username_);
517 517
518 auth->CheckLocalaccount(std::string()); 518 auth->CheckLocalaccount(std::string());
519 } 519 }
520 520
521 namespace {
522
521 // Compatible with LoginStatusConsumer::OnLoginSuccess() 523 // Compatible with LoginStatusConsumer::OnLoginSuccess()
522 static void OnSuccessQuit( 524 static void OnSuccessQuit(
523 const std::string& username, 525 const std::string& username,
524 const GaiaAuthConsumer::ClientLoginResult& credentials) { 526 const GaiaAuthConsumer::ClientLoginResult& credentials) {
525 MessageLoop::current()->Quit(); 527 MessageLoop::current()->Quit();
526 } 528 }
527 529
528 static void OnSuccessQuitAndFail( 530 static void OnSuccessQuitAndFail(
529 const std::string& username, 531 const std::string& username,
530 const GaiaAuthConsumer::ClientLoginResult& credentials) { 532 const GaiaAuthConsumer::ClientLoginResult& credentials) {
531 ADD_FAILURE() << "Login should NOT have succeeded!"; 533 ADD_FAILURE() << "Login should NOT have succeeded!";
532 MessageLoop::current()->Quit(); 534 MessageLoop::current()->Quit();
533 } 535 }
534 536
535 // Compatible with LoginStatusConsumer::OnLoginFailure() 537 // Compatible with LoginStatusConsumer::OnLoginFailure()
536 static void OnFailQuit(const std::string& error) { 538 static void OnFailQuit(const std::string& error) {
537 MessageLoop::current()->Quit(); 539 MessageLoop::current()->Quit();
538 } 540 }
539 541
540 static void OnFailQuitAndFail(const std::string& error) { 542 static void OnFailQuitAndFail(const std::string& error) {
541 ADD_FAILURE() << "Login should have succeeded!"; 543 ADD_FAILURE() << "Login should have succeeded!";
542 MessageLoop::current()->Quit(); 544 MessageLoop::current()->Quit();
543 } 545 }
544 546
547 } // anonymous namespace
548
545 TEST_F(GoogleAuthenticatorTest, LocalaccountLogin) { 549 TEST_F(GoogleAuthenticatorTest, LocalaccountLogin) {
546 // This test checks the logic that governs asynchronously reading the 550 // This test checks the logic that governs asynchronously reading the
547 // localaccount name off disk and trying to authenticate against it 551 // localaccount name off disk and trying to authenticate against it
548 // simultaneously. 552 // simultaneously.
549 MessageLoop message_loop(MessageLoop::TYPE_UI); 553 MessageLoop message_loop(MessageLoop::TYPE_UI);
550 ChromeThread ui_thread(ChromeThread::UI, &message_loop); 554 ChromeThread ui_thread(ChromeThread::UI, &message_loop);
551 555
552 MockConsumer consumer; 556 MockConsumer consumer;
553 EXPECT_CALL(consumer, OnLoginSuccess(username_, _)) 557 EXPECT_CALL(consumer, OnLoginSuccess(username_, _))
554 .WillOnce(Invoke(OnSuccessQuit)) 558 .WillOnce(Invoke(OnSuccessQuit))
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 // Post a task to cancel the login attempt. 720 // Post a task to cancel the login attempt.
717 CancelLogin(auth.get()); 721 CancelLogin(auth.get());
718 722
719 URLFetcher::set_factory(NULL); 723 URLFetcher::set_factory(NULL);
720 724
721 // Run the UI thread until we exit it gracefully. 725 // Run the UI thread until we exit it gracefully.
722 message_loop.Run(); 726 message_loop.Run();
723 } 727 }
724 728
725 } // namespace chromeos 729 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698