fake_notification_manager.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2020 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/components/phonehub/fake_notification_manager.h"
  5. #include "base/check.h"
  6. #include "base/containers/contains.h"
  7. namespace ash {
  8. namespace phonehub {
  9. FakeNotificationManager::InlineReplyMetadata::InlineReplyMetadata(
  10. int64_t notification_id,
  11. const std::u16string& inline_reply_text)
  12. : notification_id(notification_id), inline_reply_text(inline_reply_text) {}
  13. FakeNotificationManager::InlineReplyMetadata::~InlineReplyMetadata() = default;
  14. FakeNotificationManager::FakeNotificationManager() = default;
  15. FakeNotificationManager::~FakeNotificationManager() = default;
  16. void FakeNotificationManager::SetNotification(
  17. const Notification& notification) {
  18. SetNotificationsInternal(base::flat_set<Notification>{notification});
  19. }
  20. void FakeNotificationManager::RemoveNotification(int64_t id) {
  21. RemoveNotificationsInternal(base::flat_set<int64_t>{id});
  22. }
  23. void FakeNotificationManager::DismissNotification(int64_t notification_id) {
  24. DCHECK(base::Contains(id_to_notification_map_, notification_id));
  25. dismissed_notification_ids_.push_back(notification_id);
  26. NotifyNotificationsRemoved(base::flat_set<int64_t>{notification_id});
  27. }
  28. void FakeNotificationManager::SendInlineReply(
  29. int64_t notification_id,
  30. const std::u16string& inline_reply_text) {
  31. DCHECK(base::Contains(id_to_notification_map_, notification_id));
  32. inline_replies_.emplace_back(notification_id, inline_reply_text);
  33. }
  34. } // namespace phonehub
  35. } // namespace ash