Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / webui / chromeos / bluetooth_pairing_ui_browsertest-inl.h
blob01eb6f30820f55d8ee721df7986c3e2c2b7fb526
1 // Copyright 2015 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 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_window.h"
8 #include "chrome/test/base/web_ui_browser_test.h"
9 #include "content/public/browser/web_ui.h"
10 #include "content/public/test/browser_test_utils.h"
11 #include "device/bluetooth/bluetooth_adapter_factory.h"
12 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
13 #include "device/bluetooth/test/mock_bluetooth_device.h"
14 #include "testing/gmock/include/gmock/gmock.h"
16 class BluetoothPairingUITest : public WebUIBrowserTest {
17 public:
18 BluetoothPairingUITest();
19 ~BluetoothPairingUITest() override;
21 void ShowDialog();
23 private:
24 scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> mock_adapter_;
25 scoped_ptr<device::MockBluetoothDevice> mock_device_;
28 BluetoothPairingUITest::BluetoothPairingUITest() {}
29 BluetoothPairingUITest::~BluetoothPairingUITest() {}
31 void BluetoothPairingUITest::ShowDialog() {
32 mock_adapter_ = new testing::NiceMock<device::MockBluetoothAdapter>();
33 device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter_);
34 EXPECT_CALL(*mock_adapter_, IsPresent())
35 .WillRepeatedly(testing::Return(true));
36 EXPECT_CALL(*mock_adapter_, IsPowered())
37 .WillRepeatedly(testing::Return(true));
39 const bool kNotPaired = false;
40 const bool kNotConnected = false;
41 mock_device_.reset(
42 new testing::NiceMock<device::MockBluetoothDevice>(
43 nullptr,
45 "fake_bluetooth_device",
46 "11:12:13:14:15:16",
47 kNotPaired,
48 kNotConnected));
50 chromeos::BluetoothPairingDialog* dialog =
51 new chromeos::BluetoothPairingDialog(
52 browser()->window()->GetNativeWindow(), mock_device_.get());
53 dialog->Show();
55 content::WebUI* webui = dialog->GetWebUIForTest();
56 content::WebContents* webui_webcontents = webui->GetWebContents();
57 content::WaitForLoadStop(webui_webcontents);
58 SetWebUIInstance(webui);