Home | History | Annotate | Download | only in message_center
      1 // Copyright (c) 2013 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 
      5 #ifndef UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_
      6 #define UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_
      7 
      8 #include "ui/message_center/notifier_settings.h"
      9 
     10 namespace message_center {
     11 
     12 // A NotifierSettingsProvider that returns a configurable, fixed set of
     13 // notifiers and records which callbacks were called. For use in tests.
     14 class FakeNotifierSettingsProvider : public NotifierSettingsProvider {
     15  public:
     16   FakeNotifierSettingsProvider();
     17   FakeNotifierSettingsProvider(const std::vector<Notifier*>& notifiers);
     18   virtual ~FakeNotifierSettingsProvider();
     19 
     20   virtual size_t GetNotifierGroupCount() const OVERRIDE;
     21   virtual const message_center::NotifierGroup& GetNotifierGroupAt(
     22       size_t index) const OVERRIDE;
     23   virtual bool IsNotifierGroupActiveAt(size_t index) const OVERRIDE;
     24   virtual void SwitchToNotifierGroup(size_t index) OVERRIDE;
     25   virtual const message_center::NotifierGroup& GetActiveNotifierGroup() const
     26       OVERRIDE;
     27 
     28   virtual void GetNotifierList(std::vector<Notifier*>* notifiers) OVERRIDE;
     29 
     30   virtual void SetNotifierEnabled(const Notifier& notifier,
     31                                   bool enabled) OVERRIDE;
     32 
     33   virtual void OnNotifierSettingsClosing() OVERRIDE;
     34   virtual void AddObserver(NotifierSettingsObserver* observer) OVERRIDE;
     35   virtual void RemoveObserver(NotifierSettingsObserver* observer) OVERRIDE;
     36 
     37   bool WasEnabled(const Notifier& notifier);
     38   int closed_called_count();
     39 
     40   void AddGroup(NotifierGroup* group, const std::vector<Notifier*>& notifiers);
     41 
     42  private:
     43   struct NotifierGroupItem {
     44     NotifierGroup* group;
     45     std::vector<Notifier*> notifiers;
     46 
     47     NotifierGroupItem();
     48     ~NotifierGroupItem();
     49   };
     50 
     51   std::map<const Notifier*, bool> enabled_;
     52   std::vector<NotifierGroupItem> items_;
     53   int closed_called_count_;
     54   size_t active_item_index_;
     55 };
     56 
     57 }  // namespace message_center
     58 
     59 #endif  // UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_
     60