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

Side by Side Diff: chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui_browsertest-inl.h

Issue 2017113002: [Extensions] DCHECK that ExtensionFunctions respond (and only once) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "base/auto_reset.h"
5 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" 6 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
6 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_window.h" 8 #include "chrome/browser/ui/browser_window.h"
8 #include "chrome/test/base/web_ui_browser_test.h" 9 #include "chrome/test/base/web_ui_browser_test.h"
9 #include "content/public/browser/web_ui.h" 10 #include "content/public/browser/web_ui.h"
10 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/browser_test_utils.h"
11 #include "device/bluetooth/bluetooth_adapter_factory.h" 12 #include "device/bluetooth/bluetooth_adapter_factory.h"
12 #include "device/bluetooth/test/mock_bluetooth_adapter.h" 13 #include "device/bluetooth/test/mock_bluetooth_adapter.h"
13 #include "device/bluetooth/test/mock_bluetooth_device.h" 14 #include "device/bluetooth/test/mock_bluetooth_device.h"
15 #include "extensions/browser/extension_function.h"
14 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
15 17
16 class BluetoothPairingUITest : public WebUIBrowserTest { 18 class BluetoothPairingUITest : public WebUIBrowserTest {
17 public: 19 public:
18 BluetoothPairingUITest(); 20 BluetoothPairingUITest();
19 ~BluetoothPairingUITest() override; 21 ~BluetoothPairingUITest() override;
20 22
21 void ShowDialog(); 23 void ShowDialog();
22 24
23 private: 25 private:
24 scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> mock_adapter_; 26 scoped_refptr<testing::NiceMock<device::MockBluetoothAdapter>> mock_adapter_;
25 std::unique_ptr<device::MockBluetoothDevice> mock_device_; 27 std::unique_ptr<device::MockBluetoothDevice> mock_device_;
26 }; 28 };
27 29
28 BluetoothPairingUITest::BluetoothPairingUITest() {} 30 BluetoothPairingUITest::BluetoothPairingUITest() {}
29 31
30 BluetoothPairingUITest::~BluetoothPairingUITest() {} 32 BluetoothPairingUITest::~BluetoothPairingUITest() {}
31 33
32 void BluetoothPairingUITest::ShowDialog() { 34 void BluetoothPairingUITest::ShowDialog() {
35 // Since we use mocks, callbacks are never called for the bluetooth API
36 // functions. :(
37 base::AutoReset<bool> ignore_did_respond(
38 &ExtensionFunction::ignore_all_did_respond_for_testing_do_not_use, true);
33 mock_adapter_ = new testing::NiceMock<device::MockBluetoothAdapter>(); 39 mock_adapter_ = new testing::NiceMock<device::MockBluetoothAdapter>();
34 device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter_); 40 device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter_);
35 EXPECT_CALL(*mock_adapter_, IsPresent()) 41 EXPECT_CALL(*mock_adapter_, IsPresent())
36 .WillRepeatedly(testing::Return(true)); 42 .WillRepeatedly(testing::Return(true));
37 EXPECT_CALL(*mock_adapter_, IsPowered()) 43 EXPECT_CALL(*mock_adapter_, IsPowered())
38 .WillRepeatedly(testing::Return(true)); 44 .WillRepeatedly(testing::Return(true));
39 45
40 const bool kNotPaired = false; 46 const bool kNotPaired = false;
41 const bool kNotConnected = false; 47 const bool kNotConnected = false;
42 mock_device_.reset( 48 mock_device_.reset(
(...skipping 11 matching lines...) Expand all
54 chromeos::BluetoothPairingDialog* dialog = 60 chromeos::BluetoothPairingDialog* dialog =
55 new chromeos::BluetoothPairingDialog( 61 new chromeos::BluetoothPairingDialog(
56 browser()->window()->GetNativeWindow(), mock_device_.get()); 62 browser()->window()->GetNativeWindow(), mock_device_.get());
57 dialog->Show(); 63 dialog->Show();
58 64
59 content::WebUI* webui = dialog->GetWebUIForTest(); 65 content::WebUI* webui = dialog->GetWebUIForTest();
60 content::WebContents* webui_webcontents = webui->GetWebContents(); 66 content::WebContents* webui_webcontents = webui->GetWebContents();
61 content::WaitForLoadStop(webui_webcontents); 67 content::WaitForLoadStop(webui_webcontents);
62 SetWebUIInstance(webui); 68 SetWebUIInstance(webui);
63 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698