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 ~FakeNotifierSettingsProvider() override
;
22 size_t GetNotifierGroupCount() const override
;
23 const NotifierGroup
& GetNotifierGroupAt(size_t index
) const override
;
24 bool IsNotifierGroupActiveAt(size_t index
) const override
;
25 void SwitchToNotifierGroup(size_t index
) override
;
26 const NotifierGroup
& GetActiveNotifierGroup() const override
;
28 void GetNotifierList(std::vector
<Notifier
*>* notifiers
) override
;
30 void SetNotifierEnabled(const Notifier
& notifier
, bool enabled
) override
;
32 void OnNotifierSettingsClosing() override
;
33 bool NotifierHasAdvancedSettings(
34 const NotifierId
& notifier_id
) const override
;
35 void OnNotifierAdvancedSettingsRequested(
36 const NotifierId
& notifier_id
,
37 const std::string
* notification_id
) override
;
38 void AddObserver(NotifierSettingsObserver
* observer
) override
;
39 void RemoveObserver(NotifierSettingsObserver
* observer
) override
;
41 bool WasEnabled(const Notifier
& notifier
);
42 int closed_called_count();
44 void AddGroup(NotifierGroup
* group
, const std::vector
<Notifier
*>& notifiers
);
46 // For testing, this method can be used to specify a notifier that has a learn
47 // more button. This class only saves the last one that was set.
48 void SetNotifierHasAdvancedSettings(const NotifierId
& notifier_id
);
49 size_t settings_requested_count() const;
52 struct NotifierGroupItem
{
54 std::vector
<Notifier
*> notifiers
;
60 std::map
<const Notifier
*, bool> enabled_
;
61 std::vector
<NotifierGroupItem
> items_
;
62 int closed_called_count_
;
63 size_t active_item_index_
;
64 scoped_ptr
<NotifierId
> notifier_id_with_settings_handler_
;
65 size_t notifier_settings_requested_count_
;
68 } // namespace message_center
70 #endif // UI_MESSAGE_CENTER_FAKE_NOTIFIER_SETTINGS_PROVIDER_H_