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

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

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

Powered by Google App Engine
This is Rietveld 408576698