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.
5 #ifndef UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_
6 #define UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/message_center/notifier_settings.h"
11 namespace message_center
{
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
{
17 FakeNotifierSettingsProvider();
18 explicit FakeNotifierSettingsProvider(
19 const std::vector
<Notifier
*>& notifiers
);
20 virtual ~FakeNotifierSettingsProvider();
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
;
28 virtual void GetNotifierList(std::vector
<Notifier
*>* notifiers
) OVERRIDE
;
30 virtual void SetNotifierEnabled(const Notifier
& notifier
,
31 bool enabled
) OVERRIDE
;
33 virtual void OnNotifierSettingsClosing() OVERRIDE
;
34 virtual bool NotifierHasAdvancedSettings(const NotifierId
& notifier_id
) const
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
;
42 bool WasEnabled(const Notifier
& notifier
);
43 int closed_called_count();
45 void AddGroup(NotifierGroup
* group
, const std::vector
<Notifier
*>& notifiers
);
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;
53 struct NotifierGroupItem
{
55 std::vector
<Notifier
*> notifiers
;
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_
;
69 } // namespace message_center
71 #endif // UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_