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

Side by Side Diff: chrome/browser/status_icons/status_tray_unittest.cc

Issue 2767893002: Remove ScopedVector from chrome/browser/. (Closed)
Patch Set: Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/status_icons/status_tray.h"
Lei Zhang 2017/03/23 02:59:26 Blank line after.
leonhsl(Using Gerrit) 2017/03/23 15:03:17 Done.
5 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/ptr_util.h"
6 #include "chrome/browser/status_icons/status_icon.h" 8 #include "chrome/browser/status_icons/status_icon.h"
7 #include "chrome/browser/status_icons/status_tray.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/image/image_skia.h" 10 #include "ui/gfx/image/image_skia.h"
10 #include "ui/gfx/image/image_unittest_util.h" 11 #include "ui/gfx/image/image_unittest_util.h"
11 #include "ui/message_center/notifier_settings.h" 12 #include "ui/message_center/notifier_settings.h"
12 13
13 namespace { 14 namespace {
14 15
15 class MockStatusIcon : public StatusIcon { 16 class MockStatusIcon : public StatusIcon {
16 void SetImage(const gfx::ImageSkia& image) override {} 17 void SetImage(const gfx::ImageSkia& image) override {}
17 void SetToolTip(const base::string16& tool_tip) override {} 18 void SetToolTip(const base::string16& tool_tip) override {}
18 void DisplayBalloon(const gfx::ImageSkia& icon, 19 void DisplayBalloon(const gfx::ImageSkia& icon,
19 const base::string16& title, 20 const base::string16& title,
20 const base::string16& contents, 21 const base::string16& contents,
21 const message_center::NotifierId& notifier_id) override {} 22 const message_center::NotifierId& notifier_id) override {}
22 void UpdatePlatformContextMenu(StatusIconMenuModel* menu) override {} 23 void UpdatePlatformContextMenu(StatusIconMenuModel* menu) override {}
23 }; 24 };
24 25
25 class TestStatusTray : public StatusTray { 26 class TestStatusTray : public StatusTray {
26 public: 27 public:
27 StatusIcon* CreatePlatformStatusIcon( 28 std::unique_ptr<StatusIcon> CreatePlatformStatusIcon(
28 StatusIconType type, 29 StatusIconType type,
29 const gfx::ImageSkia& image, 30 const gfx::ImageSkia& image,
30 const base::string16& tool_tip) override { 31 const base::string16& tool_tip) override {
31 return new MockStatusIcon(); 32 return base::MakeUnique<MockStatusIcon>();
32 } 33 }
33 34
34 const StatusIcons& GetStatusIconsForTest() const { return status_icons(); } 35 const StatusIcons& GetStatusIconsForTest() const { return status_icons(); }
35 }; 36 };
36 37
37 StatusIcon* CreateStatusIcon(StatusTray* tray) { 38 StatusIcon* CreateStatusIcon(StatusTray* tray) {
38 // Just create a dummy icon image; the actual image is irrelevant. 39 // Just create a dummy icon image; the actual image is irrelevant.
39 return tray->CreateStatusIcon(StatusTray::OTHER_ICON, 40 return tray->CreateStatusIcon(StatusTray::OTHER_ICON,
40 gfx::test::CreateImageSkia(16, 16), 41 gfx::test::CreateImageSkia(16, 16),
41 base::string16()); 42 base::string16());
42 } 43 }
43 44
44 } // namespace 45 } // namespace
45 46
46 TEST(StatusTrayTest, Create) { 47 TEST(StatusTrayTest, Create) {
47 // Check for creation and leaks. 48 // Check for creation and leaks.
48 TestStatusTray tray; 49 TestStatusTray tray;
49 CreateStatusIcon(&tray); 50 CreateStatusIcon(&tray);
50 EXPECT_EQ(1U, tray.GetStatusIconsForTest().size()); 51 EXPECT_EQ(1U, tray.GetStatusIconsForTest().size());
51 } 52 }
52 53
53 // Make sure that removing an icon removes it from the list. 54 // Make sure that removing an icon removes it from the list.
54 TEST(StatusTrayTest, CreateRemove) { 55 TEST(StatusTrayTest, CreateRemove) {
55 TestStatusTray tray; 56 TestStatusTray tray;
56 StatusIcon* icon = CreateStatusIcon(&tray); 57 StatusIcon* icon = CreateStatusIcon(&tray);
57 EXPECT_EQ(1U, tray.GetStatusIconsForTest().size()); 58 EXPECT_EQ(1U, tray.GetStatusIconsForTest().size());
58 tray.RemoveStatusIcon(icon); 59 tray.RemoveStatusIcon(icon);
59 EXPECT_EQ(0U, tray.GetStatusIconsForTest().size()); 60 EXPECT_EQ(0U, tray.GetStatusIconsForTest().size());
60 } 61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698