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 "base/memory/scoped_ptr.h"
      9 #include "ui/message_center/notifier_settings.h"
     10 
     11 namespace message_center {
     12 
     13 // A NotifierSettingsProvider that returns a configurable, fixed set of
     14 // notifiers and records which callbacks were called. For use in tests.
     15 class FakeNotifierSettingsProvider : public NotifierSettingsProvider {
     16  public:
     17   FakeNotifierSettingsProvider();
     18   explicit FakeNotifierSettingsProvider(
     19       const std::vector<Notifier*>& notifiers);
     20   virtual ~FakeNotifierSettingsProvider();
     21 
     22   virtual size_t GetNotifierGroupCount() const OVERRIDE;
     23   virtual const NotifierGroup& GetNotifierGroupAt(size_t index) const OVERRIDE;
     24   virtual bool IsNotifierGroupActiveAt(size_t index) const OVERRIDE;
     25   virtual void SwitchToNotifierGroup(size_t index) OVERRIDE;
     26   virtual const NotifierGroup& GetActiveNotifierGroup() const 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 bool NotifierHasAdvancedSettings(const NotifierId& notifier_id) const
     35       OVERRIDE;
     36   virtual void OnNotifierAdvancedSettingsRequested(
     37       const NotifierId& notifier_id,
     38       const std::string* notification_id) OVERRIDE;
     39   virtual void AddObserver(NotifierSettingsObserver* observer) OVERRIDE;
     40   virtual void RemoveObserver(NotifierSettingsObserver* observer) OVERRIDE;
     41 
     42   bool WasEnabled(const Notifier& notifier);
     43   int closed_called_count();
     44 
     45   void AddGroup(NotifierGroup* group, const std::vector<Notifier*>& notifiers);
     46 
     47   // For testing, this method can be used to specify a notifier that has a learn
     48   // more button. This class only saves the last one that was set.
     49   void SetNotifierHasAdvancedSettings(const NotifierId& notifier_id);
     50   size_t settings_requested_count() const;
     51 
     52  private:
     53   struct NotifierGroupItem {
     54     NotifierGroup* group;
     55     std::vector<Notifier*> notifiers;
     56 
     57     NotifierGroupItem();
     58     ~NotifierGroupItem();
     59   };
     60 
     61   std::map<const Notifier*, bool> enabled_;
     62   std::vector<NotifierGroupItem> items_;
     63   int closed_called_count_;
     64   size_t active_item_index_;
     65   scoped_ptr<NotifierId> notifier_id_with_settings_handler_;
     66   size_t notifier_settings_requested_count_;
     67 };
     68 
     69 }  // namespace message_center
     70 
     71 #endif  // UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_
     72