blob: 5ab6c475345269db0c662694efc48ee1a9121c46 [file] [log] [blame]
Bret Sepulvedae6e84f72017-10-20 03:37:401// Copyright 2017 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_CHOOSER_CONTROLLER_FAKE_BLUETOOTH_CHOOSER_CONTROLLER_H_
6#define CHROME_BROWSER_CHOOSER_CONTROLLER_FAKE_BLUETOOTH_CHOOSER_CONTROLLER_H_
7
Bret Sepulveda3d1f0f32017-11-11 03:18:038#include <string>
9
Bret Sepulvedae6e84f72017-10-20 03:37:4010#include "base/macros.h"
11#include "base/strings/string16.h"
12#include "chrome/browser/chooser_controller/chooser_controller.h"
13#include "testing/gmock/include/gmock/gmock.h"
14
15// A subclass of ChooserController that pretends to be a Bluetooth device
16// chooser for testing. The result should be visually similar to the real
17// version of the dialog for interactive tests.
18class FakeBluetoothChooserController : public ChooserController {
19 public:
20 enum class BluetoothStatus {
21 UNAVAILABLE,
22 IDLE,
23 SCANNING,
24 };
25
26 enum ConnectionStatus {
27 NOT_CONNECTED = false,
28 CONNECTED = true,
29 };
30
31 enum PairStatus {
32 NOT_PAIRED = false,
33 PAIRED = true,
34 };
35
36 static constexpr int kSignalStrengthUnknown = -1;
37 static constexpr int kSignalStrengthLevel0 = 0;
38 static constexpr int kSignalStrengthLevel1 = 1;
39 static constexpr int kSignalStrengthLevel2 = 2;
40 static constexpr int kSignalStrengthLevel3 = 3;
41 static constexpr int kSignalStrengthLevel4 = 4;
42
43 struct FakeDevice {
Bret Sepulveda3d1f0f32017-11-11 03:18:0344 std::string name;
Bret Sepulvedae6e84f72017-10-20 03:37:4045 bool connected;
46 bool paired;
47 int signal_strength;
48 };
49
50 explicit FakeBluetoothChooserController(std::vector<FakeDevice> devices = {});
51 ~FakeBluetoothChooserController() override;
52
53 // ChooserController:
54 bool ShouldShowIconBeforeText() const override;
Bret Sepulvedaa4975e7a5e2017-12-18 23:16:3855 bool ShouldShowReScanButton() const override;
Bret Sepulvedae6e84f72017-10-20 03:37:4056 base::string16 GetNoOptionsText() const override;
57 base::string16 GetOkButtonLabel() const override;
58 size_t NumOptions() const override;
59 int GetSignalStrengthLevel(size_t index) const override;
60 base::string16 GetOption(size_t index) const override;
61 bool IsConnected(size_t index) const override;
62 bool IsPaired(size_t index) const override;
63 base::string16 GetStatus() const override;
64 MOCK_METHOD0(RefreshOptions, void());
65 MOCK_METHOD1(Select, void(const std::vector<size_t>& indices));
66 MOCK_METHOD0(Cancel, void());
67 MOCK_METHOD0(Close, void());
68 MOCK_CONST_METHOD0(OpenHelpCenterUrl, void());
69 MOCK_CONST_METHOD0(OpenAdapterOffHelpUrl, void());
70
71 void SetBluetoothStatus(BluetoothStatus status);
72 void AddDevice(FakeDevice device);
73 void RemoveDevice(size_t index);
74 void UpdateDevice(size_t index, FakeDevice new_device);
75
76 private:
77 BluetoothStatus status_ = BluetoothStatus::UNAVAILABLE;
78 std::vector<FakeDevice> devices_;
79
80 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothChooserController);
81};
82
83#endif // CHROME_BROWSER_CHOOSER_CONTROLLER_FAKE_BLUETOOTH_CHOOSER_CONTROLLER_H_