Home | History | Annotate | Download | only in login
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_TEST_ATTEMPT_STATE_H_
      6 #define CHROME_BROWSER_CHROMEOS_LOGIN_TEST_ATTEMPT_STATE_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "chrome/browser/chromeos/login/auth_attempt_state.h"
     12 #include "chrome/browser/chromeos/login/login_status_consumer.h"
     13 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
     14 
     15 namespace chromeos {
     16 
     17 class TestAttemptState : public AuthAttemptState {
     18  public:
     19   TestAttemptState(const std::string& username,
     20                    const std::string& password,
     21                    const std::string& ascii_hash,
     22                    const std::string& login_token,
     23                    const std::string& login_captcha,
     24                    const bool user_is_new);
     25 
     26   TestAttemptState(const std::string& username, const std::string& ascii_hash);
     27 
     28   virtual ~TestAttemptState();
     29 
     30   // Act as though an online login attempt completed already.
     31   void PresetOnlineLoginStatus(
     32       const GaiaAuthConsumer::ClientLoginResult& credentials,
     33       const LoginFailure& outcome);
     34 
     35   // The next attempt will not allow HOSTED accounts to log in.
     36   void DisableHosted();
     37 
     38   // Act as though an cryptohome login attempt completed already.
     39   void PresetCryptohomeStatus(bool cryptohome_outcome, int cryptohome_code);
     40 
     41   // To allow state to be queried on the main thread during tests.
     42   virtual bool online_complete() { return online_complete_; }
     43   virtual const LoginFailure& online_outcome() { return online_outcome_; }
     44   virtual const GaiaAuthConsumer::ClientLoginResult& credentials() {
     45     return credentials_;
     46   }
     47   virtual bool is_first_time_user() { return is_first_time_user_; }
     48   virtual GaiaAuthFetcher::HostedAccountsSetting hosted_policy() {
     49     return hosted_policy_;
     50   }
     51 
     52   virtual bool cryptohome_complete() { return cryptohome_complete_; }
     53   virtual bool cryptohome_outcome() { return cryptohome_outcome_; }
     54   virtual int cryptohome_code() { return cryptohome_code_; }
     55 
     56  private:
     57   DISALLOW_COPY_AND_ASSIGN(TestAttemptState);
     58 };
     59 
     60 }  // namespace chromeos
     61 
     62 #endif  // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_ATTEMPT_STATE_H_
     63