fake_bluetooth_detailed_view.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2021 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. #include "ash/system/bluetooth/fake_bluetooth_detailed_view.h"
  5. #include "ash/system/bluetooth/bluetooth_device_list_item_view.h"
  6. #include "ash/system/tray/tri_view.h"
  7. #include "ui/base/l10n/l10n_util.h"
  8. #include "ui/views/controls/label.h"
  9. namespace ash {
  10. FakeBluetoothDetailedView::FakeBluetoothDetailedView(Delegate* delegate)
  11. : BluetoothDetailedView(delegate),
  12. device_list_(std::make_unique<views::View>()) {}
  13. FakeBluetoothDetailedView::~FakeBluetoothDetailedView() = default;
  14. views::View* FakeBluetoothDetailedView::GetAsView() {
  15. return this;
  16. }
  17. void FakeBluetoothDetailedView::UpdateBluetoothEnabledState(bool enabled) {
  18. last_bluetooth_enabled_state_ = enabled;
  19. }
  20. BluetoothDeviceListItemView* FakeBluetoothDetailedView::AddDeviceListItem() {
  21. return device_list_->AddChildView(
  22. new BluetoothDeviceListItemView(/*listener=*/nullptr));
  23. }
  24. ash::TriView* FakeBluetoothDetailedView::AddDeviceListSubHeader(
  25. const gfx::VectorIcon& /*icon*/,
  26. int text_id) {
  27. std::unique_ptr<TriView> sub_header = std::make_unique<TriView>();
  28. sub_header->AddView(TriView::Container::CENTER,
  29. new views::Label(l10n_util::GetStringUTF16(text_id)));
  30. device_list_->AddChildView(sub_header.get());
  31. return sub_header.release();
  32. }
  33. void FakeBluetoothDetailedView::NotifyDeviceListChanged() {
  34. notify_device_list_changed_call_count_++;
  35. }
  36. views::View* FakeBluetoothDetailedView::device_list() {
  37. return device_list_.get();
  38. }
  39. void FakeBluetoothDetailedView::OnViewClicked(views::View* view) {
  40. last_clicked_device_list_item_ =
  41. static_cast<BluetoothDeviceListItemView*>(view);
  42. }
  43. } // namespace ash