#include "chrome/browser/ui/views/device_chooser_content_view.h"
#include <memory>
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/views/chrome_views_test_base.h"
#include "components/permissions/fake_bluetooth_chooser_controller.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/list_selection_model.h"
#include "ui/events/base_event_utils.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/controls/table/table_view.h"
#include "ui/views/controls/table/table_view_observer.h"
#include "ui/views/controls/throbber.h"
#include "ui/views/test/button_test_api.h"
FakeBluetoothChooserController;
namespace {
class MockTableViewObserver : public views::TableViewObserver { … };
}
class DeviceChooserContentViewTest : public ChromeViewsTestBase { … };
TEST_F(DeviceChooserContentViewTest, InitialState) { … }
TEST_F(DeviceChooserContentViewTest, AddOption) { … }
TEST_F(DeviceChooserContentViewTest, RemoveOption) { … }
TEST_F(DeviceChooserContentViewTest, UpdateOption) { … }
TEST_F(DeviceChooserContentViewTest, SelectAndDeselectAnOption) { … }
TEST_F(DeviceChooserContentViewTest, BluetoothIsOff) { … }
TEST_F(DeviceChooserContentViewTest, BluetoothIsOnThenOffNoDevices) { … }
TEST_F(DeviceChooserContentViewTest, TurnBluetoothOffAndOn) { … }
#if BUILDFLAG(IS_MAC)
TEST_F(DeviceChooserContentViewTest, BluetoothPermissionDenied) {
AddUnpairedDevice();
controller()->SetBluetoothPermission(false);
EXPECT_FALSE(table_parent()->GetVisible());
EXPECT_FALSE(no_options_view()->GetVisible());
EXPECT_FALSE(adapter_off_view()->GetVisible());
EXPECT_TRUE(adapter_unauthorized_view()->GetVisible());
EXPECT_FALSE(throbber()->GetVisible());
EXPECT_TRUE(re_scan_button()->GetVisible());
EXPECT_FALSE(re_scan_button()->GetEnabled());
controller()->RemoveDevice(0);
controller()->SetBluetoothPermission(true);
ExpectNoDevicesWithMessageVisible();
EXPECT_FALSE(adapter_off_view()->GetVisible());
EXPECT_FALSE(adapter_unauthorized_view()->GetVisible());
EXPECT_FALSE(throbber()->GetVisible());
EXPECT_TRUE(re_scan_button()->GetVisible());
EXPECT_TRUE(re_scan_button()->GetEnabled());
}
#endif
TEST_F(DeviceChooserContentViewTest, ScanForDevices) { … }
TEST_F(DeviceChooserContentViewTest, ClickAdapterOffHelpLink) { … }
TEST_F(DeviceChooserContentViewTest, ClickRescanButton) { … }
TEST_F(DeviceChooserContentViewTest, ClickHelpButton) { … }
TEST_F(DeviceChooserContentViewTest, SetTableViewAlwaysDisabled) { … }