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

Side by Side Diff: ui/message_center/views/notification_view_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 "ui/message_center/views/notification_view.h" 5 #include "ui/message_center/views/notification_view.h"
6 6
7 #include <memory>
8
7 #include "base/macros.h" 9 #include "base/macros.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkCanvas.h" 13 #include "third_party/skia/include/core/SkCanvas.h"
13 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
14 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 15 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
15 #include "ui/events/event_processor.h" 16 #include "ui/events/event_processor.h"
16 #include "ui/events/event_utils.h" 17 #include "ui/events/event_utils.h"
17 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
18 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
20 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
21 #include "ui/message_center/message_center_style.h" 22 #include "ui/message_center/message_center_style.h"
22 #include "ui/message_center/notification.h" 23 #include "ui/message_center/notification.h"
23 #include "ui/message_center/notification_list.h" 24 #include "ui/message_center/notification_list.h"
24 #include "ui/message_center/notification_types.h" 25 #include "ui/message_center/notification_types.h"
25 #include "ui/message_center/views/constants.h" 26 #include "ui/message_center/views/constants.h"
26 #include "ui/message_center/views/message_center_controller.h" 27 #include "ui/message_center/views/message_center_controller.h"
27 #include "ui/message_center/views/notification_button.h" 28 #include "ui/message_center/views/notification_button.h"
28 #include "ui/message_center/views/proportional_image_view.h" 29 #include "ui/message_center/views/proportional_image_view.h"
29 #include "ui/views/controls/button/image_button.h" 30 #include "ui/views/controls/button/image_button.h"
30 #include "ui/views/layout/fill_layout.h" 31 #include "ui/views/layout/fill_layout.h"
31 #include "ui/views/test/views_test_base.h" 32 #include "ui/views/test/views_test_base.h"
32 #include "ui/views/test/widget_test.h" 33 #include "ui/views/test/widget_test.h"
33 #include "ui/views/widget/widget_delegate.h" 34 #include "ui/views/widget/widget_delegate.h"
34 35
35 namespace { 36 namespace {
36 37
37 scoped_ptr<ui::GestureEvent> GenerateGestureEvent(ui::EventType type) { 38 std::unique_ptr<ui::GestureEvent> GenerateGestureEvent(ui::EventType type) {
38 ui::GestureEventDetails detail(type); 39 ui::GestureEventDetails detail(type);
39 scoped_ptr<ui::GestureEvent> event( 40 std::unique_ptr<ui::GestureEvent> event(
40 new ui::GestureEvent(0, 0, 0, base::TimeDelta(), detail)); 41 new ui::GestureEvent(0, 0, 0, base::TimeDelta(), detail));
41 return event; 42 return event;
42 } 43 }
43 44
44 scoped_ptr<ui::GestureEvent> GenerateGestureVerticalScrollUpdateEvent(int dx) { 45 std::unique_ptr<ui::GestureEvent> GenerateGestureVerticalScrollUpdateEvent(
46 int dx) {
45 ui::GestureEventDetails detail(ui::ET_GESTURE_SCROLL_UPDATE, dx, 0); 47 ui::GestureEventDetails detail(ui::ET_GESTURE_SCROLL_UPDATE, dx, 0);
46 scoped_ptr<ui::GestureEvent> event( 48 std::unique_ptr<ui::GestureEvent> event(
47 new ui::GestureEvent(0, 0, 0, base::TimeDelta(), detail)); 49 new ui::GestureEvent(0, 0, 0, base::TimeDelta(), detail));
48 return event; 50 return event;
49 } 51 }
50 52
51 } // anonymouse namespace 53 } // anonymouse namespace
52 54
53 namespace message_center { 55 namespace message_center {
54 56
55 // A test delegate used for tests that deal with the notification settings 57 // A test delegate used for tests that deal with the notification settings
56 // button. 58 // button.
(...skipping 19 matching lines...) Expand all
76 NotificationView* notification_view() const { 78 NotificationView* notification_view() const {
77 return notification_view_.get(); 79 return notification_view_.get();
78 } 80 }
79 Notification* notification() { return notification_.get(); } 81 Notification* notification() { return notification_.get(); }
80 RichNotificationData* data() { return data_.get(); } 82 RichNotificationData* data() { return data_.get(); }
81 83
82 // Overridden from MessageCenterController: 84 // Overridden from MessageCenterController:
83 void ClickOnNotification(const std::string& notification_id) override; 85 void ClickOnNotification(const std::string& notification_id) override;
84 void RemoveNotification(const std::string& notification_id, 86 void RemoveNotification(const std::string& notification_id,
85 bool by_user) override; 87 bool by_user) override;
86 scoped_ptr<ui::MenuModel> CreateMenuModel( 88 std::unique_ptr<ui::MenuModel> CreateMenuModel(
87 const NotifierId& notifier_id, 89 const NotifierId& notifier_id,
88 const base::string16& display_source) override; 90 const base::string16& display_source) override;
89 bool HasClickedListener(const std::string& notification_id) override; 91 bool HasClickedListener(const std::string& notification_id) override;
90 void ClickOnNotificationButton(const std::string& notification_id, 92 void ClickOnNotificationButton(const std::string& notification_id,
91 int button_index) override; 93 int button_index) override;
92 void ClickOnSettingsButton(const std::string& notification_id) override; 94 void ClickOnSettingsButton(const std::string& notification_id) override;
93 95
94 protected: 96 protected:
95 // Used to fill bitmaps returned by CreateBitmap(). 97 // Used to fill bitmaps returned by CreateBitmap().
96 static const SkColor kBitmapColor = SK_ColorGREEN; 98 static const SkColor kBitmapColor = SK_ColorGREEN;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 193
192 bool IsRemoved(const std::string& notification_id) const { 194 bool IsRemoved(const std::string& notification_id) const {
193 return (removed_ids_.find(notification_id) != removed_ids_.end()); 195 return (removed_ids_.find(notification_id) != removed_ids_.end());
194 } 196 }
195 197
196 void RemoveNotificationView() { notification_view_.reset(); } 198 void RemoveNotificationView() { notification_view_.reset(); }
197 199
198 private: 200 private:
199 std::set<std::string> removed_ids_; 201 std::set<std::string> removed_ids_;
200 202
201 scoped_ptr<RichNotificationData> data_; 203 std::unique_ptr<RichNotificationData> data_;
202 scoped_ptr<Notification> notification_; 204 std::unique_ptr<Notification> notification_;
203 scoped_ptr<NotificationView> notification_view_; 205 std::unique_ptr<NotificationView> notification_view_;
204 206
205 DISALLOW_COPY_AND_ASSIGN(NotificationViewTest); 207 DISALLOW_COPY_AND_ASSIGN(NotificationViewTest);
206 }; 208 };
207 209
208 NotificationViewTest::NotificationViewTest() { 210 NotificationViewTest::NotificationViewTest() {
209 } 211 }
210 212
211 NotificationViewTest::~NotificationViewTest() { 213 NotificationViewTest::~NotificationViewTest() {
212 } 214 }
213 215
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // For this test, this method should not be invoked. 251 // For this test, this method should not be invoked.
250 NOTREACHED(); 252 NOTREACHED();
251 } 253 }
252 254
253 void NotificationViewTest::RemoveNotification( 255 void NotificationViewTest::RemoveNotification(
254 const std::string& notification_id, 256 const std::string& notification_id,
255 bool by_user) { 257 bool by_user) {
256 removed_ids_.insert(notification_id); 258 removed_ids_.insert(notification_id);
257 } 259 }
258 260
259 scoped_ptr<ui::MenuModel> NotificationViewTest::CreateMenuModel( 261 std::unique_ptr<ui::MenuModel> NotificationViewTest::CreateMenuModel(
260 const NotifierId& notifier_id, 262 const NotifierId& notifier_id,
261 const base::string16& display_source) { 263 const base::string16& display_source) {
262 // For this test, this method should not be invoked. 264 // For this test, this method should not be invoked.
263 NOTREACHED(); 265 NOTREACHED();
264 return nullptr; 266 return nullptr;
265 } 267 }
266 268
267 bool NotificationViewTest::HasClickedListener( 269 bool NotificationViewTest::HasClickedListener(
268 const std::string& notification_id) { 270 const std::string& notification_id) {
269 return true; 271 return true;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 TEST_F(NotificationViewTest, Pinned) { 701 TEST_F(NotificationViewTest, Pinned) {
700 notification()->set_pinned(true); 702 notification()->set_pinned(true);
701 703
702 UpdateNotificationViews(); 704 UpdateNotificationViews();
703 EXPECT_EQ(NULL, GetCloseButton()); 705 EXPECT_EQ(NULL, GetCloseButton());
704 } 706 }
705 707
706 #endif // defined(OS_CHROMEOS) 708 #endif // defined(OS_CHROMEOS)
707 709
708 } // namespace message_center 710 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/notification_view.cc ('k') | ui/message_center/views/notifier_settings_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698