1 // Copyright 2014 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.
5 #ifndef COMPONENTS_PAIRING_FAKE_HOST_PAIRING_CONTROLLER_H_
6 #define COMPONENTS_PAIRING_FAKE_HOST_PAIRING_CONTROLLER_H_
8 #include "base/macros.h"
9 #include "base/observer_list.h"
10 #include "base/time/time.h"
11 #include "components/pairing/host_pairing_controller.h"
13 namespace pairing_chromeos
{
15 class FakeHostPairingController
16 : public HostPairingController
,
17 public HostPairingController::Observer
{
19 typedef HostPairingController::Observer Observer
;
21 // Config is a comma separated list of key-value pairs separated by colon.
23 // * async_duration - integer. Default: 3000.
24 // * start_after_update - {0,1}. Default: 0.
25 // * fail_enrollment - {0,1}. Default: 0.
26 // * code - 6 digits or empty string. Default: empty string. If strings is
27 // empty, random code is generated.
28 // * device_name - string. Default: "Chromebox-01".
29 // * domain - string. Default: "example.com".
30 explicit FakeHostPairingController(const std::string
& config
);
31 ~FakeHostPairingController() override
;
33 // Applies given |config| to flow.
34 void ApplyConfig(const std::string
& config
);
37 void ChangeStage(Stage new_stage
);
38 void ChangeStageLater(Stage new_stage
);
40 // HostPairingController:
41 void AddObserver(Observer
* observer
) override
;
42 void RemoveObserver(Observer
* observer
) override
;
43 Stage
GetCurrentStage() override
;
44 void StartPairing() override
;
45 std::string
GetDeviceName() override
;
46 std::string
GetConfirmationCode() override
;
47 std::string
GetEnrollmentDomain() override
;
48 void OnUpdateStatusChanged(UpdateStatus update_status
) override
;
49 void OnEnrollmentStatusChanged(EnrollmentStatus enrollment_status
) override
;
50 void SetPermanentId(const std::string
& permanent_id
) override
;
52 // HostPairingController::Observer:
53 void PairingStageChanged(Stage new_stage
) override
;
55 base::ObserverList
<Observer
> observers_
;
57 std::string device_name_
;
58 std::string confirmation_code_
;
59 base::TimeDelta async_duration_
;
61 // If this flag is true error happens on |STAGE_ENROLLING| once.
62 bool enrollment_should_fail_
;
64 // Controller starts its work like if update and reboot already happened.
65 bool start_after_update_
;
67 std::string enrollment_domain_
;
69 DISALLOW_COPY_AND_ASSIGN(FakeHostPairingController
);
72 } // namespace pairing_chromeos
74 #endif // COMPONENTS_PAIRING_FAKE_HOST_PAIRING_CONTROLLER_H_