blob: 29479fcacfb3ca10abda58eedac34997da18b004 [file] [log] [blame]
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/callback_helpers.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "content/public/browser/bluetooth_delegate.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#if PAIR_BLUETOOTH_ON_DEMAND()
namespace {
using DeviceCredentialsPromptResult =
::content::BluetoothDelegate::DeviceCredentialsPromptResult;
const std::u16string kDeviceIdentifier = u"test-device";
} // namespace
class BluetoothDeviceCredentialsViewBrowserTest : public DialogBrowserTest {
public:
BluetoothDeviceCredentialsViewBrowserTest() = default;
~BluetoothDeviceCredentialsViewBrowserTest() override = default;
void DialogCallback(DeviceCredentialsPromptResult status,
const std::u16string& result) {}
void ShowUi(const std::string& name) override {
chrome::ShowBluetoothDeviceCredentialsDialog(
browser()->tab_strip_model()->GetActiveWebContents(), kDeviceIdentifier,
base::BindOnce(
&BluetoothDeviceCredentialsViewBrowserTest::DialogCallback,
weak_factory_.GetWeakPtr()));
}
private:
base::WeakPtrFactory<BluetoothDeviceCredentialsViewBrowserTest> weak_factory_{
this};
};
IN_PROC_BROWSER_TEST_F(BluetoothDeviceCredentialsViewBrowserTest,
InvokeUi_default) {
ShowAndVerifyUi();
}
#endif // PAIR_BLUETOOTH_ON_DEMAND()