From ae3a4ca0b59ba7df4e2f4ba356658d16000e0692 Mon Sep 17 00:00:00 2001 From: hai007 Date: Wed, 15 Mar 2023 13:05:37 -0700 Subject: [PATCH] Create fake notification controller observer for further testing in presenter and ui_broker. PiperOrigin-RevId: 516907638 --- ...st_pair_notification_controller_observer.h | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 fastpair/ui/fast_pair/fake_fast_pair_notification_controller_observer.h diff --git a/fastpair/ui/fast_pair/fake_fast_pair_notification_controller_observer.h b/fastpair/ui/fast_pair/fake_fast_pair_notification_controller_observer.h new file mode 100644 index 00000000..3eebfdb7 --- /dev/null +++ b/fastpair/ui/fast_pair/fake_fast_pair_notification_controller_observer.h @@ -0,0 +1,55 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_UI_FAST_PAIR_FAKE_FAST_PAIR_NOTIFICATION_CONTROLLER_OBSERVER_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_UI_FAST_PAIR_FAKE_FAST_PAIR_NOTIFICATION_CONTROLLER_OBSERVER_H_ + +#include +#include +#include + +#include "fastpair/repository/device_metadata.h" +#include "fastpair/ui/fast_pair/fast_pair_notification_controller.h" + +namespace nearby { +namespace fastpair { +class FakeFastPairNotificationControllerObserver + : public FastPairNotificationController::Observer { + public: + void OnUpdateDevice(DeviceMetadata& device) override { + device_metadata_name_list_.push_back(device.GetDetails().name()); + on_update_device_count_++; + } + + bool CheckDeviceMetadataListContainTestDevice( + const std::string& device_name) { + auto it = std::find(device_metadata_name_list_.begin(), + device_metadata_name_list_.end(), device_name); + return it != device_metadata_name_list_.end(); + } + + int on_update_device_count() { return on_update_device_count_; } + + std::vector device_metadata_name_list() { + return device_metadata_name_list_; + } + + private: + std::vector device_metadata_name_list_; + int on_update_device_count_ = 0; +}; +} // namespace fastpair +} // namespace nearby + +#endif // THIRD_PARTY_NEARBY_FASTPAIR_UI_FAST_PAIR_FAKE_FAST_PAIR_NOTIFICATION_CONTROLLER_OBSERVER_H_