Index: chrome/browser/notifications/notification_test_util.cc |
diff --git a/chrome/browser/notifications/notification_test_util.cc b/chrome/browser/notifications/notification_test_util.cc |
index fa8bdd4ab1ec7444c2a5d4f1aa6666601704a9a0..5a762a1f0e337761321aa11d5ebb4c7abc6efbda 100644 |
--- a/chrome/browser/notifications/notification_test_util.cc |
+++ b/chrome/browser/notifications/notification_test_util.cc |
@@ -11,65 +11,62 @@ MockNotificationDelegate::~MockNotificationDelegate() {} |
std::string MockNotificationDelegate::id() const { return id_; } |
-// TODO(peter): |notification_| should be initialized with the correct origin. |
-StubNotificationUIManager::StubNotificationUIManager(const GURL& welcome_origin) |
- : notification_(GURL(), |
- base::string16(), |
- base::string16(), |
- gfx::Image(), |
- base::string16(), |
- base::string16(), |
- new MockNotificationDelegate("stub")), |
- profile_(NULL), |
- welcome_origin_(welcome_origin), |
- welcomed_(false), |
- added_notifications_(0U) { |
-} |
+// ----------------------------------------------------------------------------- |
+ |
+StubNotificationUIManager::StubNotificationUIManager() {} |
StubNotificationUIManager::~StubNotificationUIManager() {} |
+unsigned int StubNotificationUIManager::GetNotificationCount() const { |
+ return notifications_.size(); |
+} |
+ |
+const Notification& StubNotificationUIManager::GetNotificationAt( |
+ unsigned int index) const { |
+ DCHECK_GT(GetNotificationCount(), index); |
+ return notifications_[index].first; |
+} |
+ |
void StubNotificationUIManager::Add(const Notification& notification, |
Profile* profile) { |
- // Make a deep copy of the notification that we can inspect. |
- notification_ = notification; |
- profile_ = profile; |
- ++added_notifications_; |
+ notifications_.push_back(std::make_pair(notification, profile)); |
- if (notification.origin_url() == welcome_origin_) |
- welcomed_ = true; |
+ // Fire the Display() event on the delegate. |
+ notification.delegate()->Display(); |
} |
bool StubNotificationUIManager::Update(const Notification& notification, |
Profile* profile) { |
- // Make a deep copy of the notification that we can inspect. |
- notification_ = notification; |
- profile_ = profile; |
- return true; |
+ return false; |
} |
const Notification* StubNotificationUIManager::FindById( |
const std::string& delegate_id, |
ProfileID profile_id) const { |
- if (notification_.delegate_id() == delegate_id && profile_ == profile_id) |
- return ¬ification_; |
- else |
- return NULL; |
+ return nullptr; |
} |
bool StubNotificationUIManager::CancelById(const std::string& delegate_id, |
ProfileID profile_id) { |
- dismissed_id_ = delegate_id; |
- return true; |
+ auto iter = notifications_.begin(); |
+ for (; iter != notifications_.end(); ++iter) { |
+ if (iter->first.delegate_id() != delegate_id || |
+ iter->second != profile_id) |
+ continue; |
+ |
+ iter->first.delegate()->Close(false /* by_user */); |
+ notifications_.erase(iter); |
+ return true; |
+ } |
+ |
+ return false; |
} |
std::set<std::string> |
StubNotificationUIManager::GetAllIdsByProfileAndSourceOrigin( |
Profile* profile, |
const GURL& source) { |
- std::set<std::string> delegate_ids; |
- if (source == notification_.origin_url() && profile->IsSameProfile(profile_)) |
- delegate_ids.insert(notification_.delegate_id()); |
- return delegate_ids; |
+ return std::set<std::string>(); |
} |
bool StubNotificationUIManager::CancelAllBySourceOrigin( |