Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: chrome/browser/notifications/extension_welcome_notification_unittest.cc

Issue 624173002: replace OVERRIDE and FINAL with override and final in chrome/browser/[j-q]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/notifications/extension_welcome_notification.h" 5 #include "chrome/browser/notifications/extension_welcome_notification.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 21 matching lines...) Expand all
32 } 32 }
33 33
34 int add_notification_calls() { return add_notification_calls_; } 34 int add_notification_calls() { return add_notification_calls_; }
35 int remove_notification_calls() { return remove_notification_calls_; } 35 int remove_notification_calls() { return remove_notification_calls_; }
36 int notifications_with_shown_as_popup() { 36 int notifications_with_shown_as_popup() {
37 return notifications_with_shown_as_popup_; 37 return notifications_with_shown_as_popup_;
38 } 38 }
39 39
40 // message_center::FakeMessageCenter Overrides 40 // message_center::FakeMessageCenter Overrides
41 virtual message_center::Notification* FindVisibleNotificationById( 41 virtual message_center::Notification* FindVisibleNotificationById(
42 const std::string& id) OVERRIDE { 42 const std::string& id) override {
43 if (last_notification.get() && last_notification->id() == id) 43 if (last_notification.get() && last_notification->id() == id)
44 return last_notification.get(); 44 return last_notification.get();
45 return NULL; 45 return NULL;
46 } 46 }
47 47
48 virtual void AddNotification( 48 virtual void AddNotification(
49 scoped_ptr<message_center::Notification> notification) OVERRIDE { 49 scoped_ptr<message_center::Notification> notification) override {
50 EXPECT_FALSE(last_notification.get()); 50 EXPECT_FALSE(last_notification.get());
51 last_notification.swap(notification); 51 last_notification.swap(notification);
52 add_notification_calls_++; 52 add_notification_calls_++;
53 if (last_notification->shown_as_popup()) 53 if (last_notification->shown_as_popup())
54 notifications_with_shown_as_popup_++; 54 notifications_with_shown_as_popup_++;
55 } 55 }
56 56
57 virtual void RemoveNotification(const std::string& id, 57 virtual void RemoveNotification(const std::string& id,
58 bool by_user) OVERRIDE { 58 bool by_user) override {
59 EXPECT_TRUE(last_notification.get()); 59 EXPECT_TRUE(last_notification.get());
60 last_notification.reset(); 60 last_notification.reset();
61 remove_notification_calls_++; 61 remove_notification_calls_++;
62 } 62 }
63 63
64 void CloseCurrentNotification() { 64 void CloseCurrentNotification() {
65 EXPECT_TRUE(last_notification.get()); 65 EXPECT_TRUE(last_notification.get());
66 last_notification->delegate()->Close(true); 66 last_notification->delegate()->Close(true);
67 RemoveNotification(last_notification->id(), true); 67 RemoveNotification(last_notification->id(), true);
68 } 68 }
69 69
70 private: 70 private:
71 scoped_ptr<message_center::Notification> last_notification; 71 scoped_ptr<message_center::Notification> last_notification;
72 int add_notification_calls_; 72 int add_notification_calls_;
73 int remove_notification_calls_; 73 int remove_notification_calls_;
74 int notifications_with_shown_as_popup_; 74 int notifications_with_shown_as_popup_;
75 75
76 DISALLOW_COPY_AND_ASSIGN(MockMessageCenter); 76 DISALLOW_COPY_AND_ASSIGN(MockMessageCenter);
77 }; 77 };
78 78
79 class WelcomeNotificationDelegate 79 class WelcomeNotificationDelegate
80 : public ExtensionWelcomeNotification::Delegate { 80 : public ExtensionWelcomeNotification::Delegate {
81 public: 81 public:
82 WelcomeNotificationDelegate() 82 WelcomeNotificationDelegate()
83 : start_time_(base::Time::Now()), 83 : start_time_(base::Time::Now()),
84 message_center_(new MockMessageCenter()) { 84 message_center_(new MockMessageCenter()) {
85 } 85 }
86 86
87 // ExtensionWelcomeNotification::Delegate 87 // ExtensionWelcomeNotification::Delegate
88 virtual message_center::MessageCenter* GetMessageCenter() OVERRIDE { 88 virtual message_center::MessageCenter* GetMessageCenter() override {
89 return message_center_.get(); 89 return message_center_.get();
90 } 90 }
91 91
92 virtual base::Time GetCurrentTime() OVERRIDE { 92 virtual base::Time GetCurrentTime() override {
93 return start_time_ + elapsed_time_; 93 return start_time_ + elapsed_time_;
94 } 94 }
95 95
96 virtual void PostTask( 96 virtual void PostTask(
97 const tracked_objects::Location& from_here, 97 const tracked_objects::Location& from_here,
98 const base::Closure& task) OVERRIDE { 98 const base::Closure& task) override {
99 EXPECT_TRUE(pending_task_.is_null()); 99 EXPECT_TRUE(pending_task_.is_null());
100 pending_task_ = task; 100 pending_task_ = task;
101 } 101 }
102 102
103 // WelcomeNotificationDelegate 103 // WelcomeNotificationDelegate
104 MockMessageCenter* message_center() const { return message_center_.get(); } 104 MockMessageCenter* message_center() const { return message_center_.get(); }
105 105
106 base::Time GetStartTime() const { return start_time_; } 106 base::Time GetStartTime() const { return start_time_; }
107 107
108 void SetElapsedTime(base::TimeDelta elapsed_time) { 108 void SetElapsedTime(base::TimeDelta elapsed_time) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void SetInt64Pref(const char* path, int64 value) const { 202 void SetInt64Pref(const char* path, int64 value) const {
203 profile_->GetPrefs()->SetInt64(path, value); 203 profile_->GetPrefs()->SetInt64(path, value);
204 } 204 }
205 205
206 private: 206 private:
207 class TestNotificationDelegate : public NotificationDelegate { 207 class TestNotificationDelegate : public NotificationDelegate {
208 public: 208 public:
209 explicit TestNotificationDelegate(const std::string& id) : id_(id) {} 209 explicit TestNotificationDelegate(const std::string& id) : id_(id) {}
210 210
211 // Overridden from NotificationDelegate: 211 // Overridden from NotificationDelegate:
212 virtual void Display() OVERRIDE {} 212 virtual void Display() override {}
213 virtual void Error() OVERRIDE {} 213 virtual void Error() override {}
214 virtual void Close(bool by_user) OVERRIDE {} 214 virtual void Close(bool by_user) override {}
215 virtual void Click() OVERRIDE {} 215 virtual void Click() override {}
216 virtual void ButtonClick(int index) OVERRIDE {} 216 virtual void ButtonClick(int index) override {}
217 217
218 virtual std::string id() const OVERRIDE { return id_; } 218 virtual std::string id() const override { return id_; }
219 219
220 virtual content::WebContents* GetWebContents() const OVERRIDE { 220 virtual content::WebContents* GetWebContents() const override {
221 return NULL; 221 return NULL;
222 } 222 }
223 223
224 private: 224 private:
225 virtual ~TestNotificationDelegate() {} 225 virtual ~TestNotificationDelegate() {}
226 226
227 const std::string id_; 227 const std::string id_;
228 228
229 DISALLOW_COPY_AND_ASSIGN(TestNotificationDelegate); 229 DISALLOW_COPY_AND_ASSIGN(TestNotificationDelegate);
230 }; 230 };
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 EXPECT_TRUE(task_runner()->GetPendingTasks().empty()); 542 EXPECT_TRUE(task_runner()->GetPendingTasks().empty());
543 EXPECT_EQ(message_center()->add_notification_calls(), 0); 543 EXPECT_EQ(message_center()->add_notification_calls(), 0);
544 EXPECT_EQ(message_center()->remove_notification_calls(), 0); 544 EXPECT_EQ(message_center()->remove_notification_calls(), 0);
545 EXPECT_EQ(message_center()->notifications_with_shown_as_popup(), 0); 545 EXPECT_EQ(message_center()->notifications_with_shown_as_popup(), 0);
546 EXPECT_FALSE(GetBooleanPref(prefs::kWelcomeNotificationDismissed)); 546 EXPECT_FALSE(GetBooleanPref(prefs::kWelcomeNotificationDismissed));
547 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationDismissedLocal)); 547 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationDismissedLocal));
548 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationPreviouslyPoppedUp)); 548 EXPECT_TRUE(GetBooleanPref(prefs::kWelcomeNotificationPreviouslyPoppedUp));
549 EXPECT_EQ(GetInt64Pref(prefs::kWelcomeNotificationExpirationTimestamp), 1); 549 EXPECT_EQ(GetInt64Pref(prefs::kWelcomeNotificationExpirationTimestamp), 1);
550 } 550 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698