| OLD | NEW |
| 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/status_icons/status_icon.h" | 8 #include "chrome/browser/status_icons/status_icon.h" |
| 9 #include "chrome/browser/status_icons/status_tray.h" | 9 #include "chrome/browser/status_icons/status_tray.h" |
| 10 #include "grit/chrome_unscaled_resources.h" | 10 #include "grit/chrome_unscaled_resources.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
| 14 #include "ui/message_center/notifier_settings.h" |
| 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) override {} | 21 const base::string16& contents, |
| 22 const message_center::NotifierId& notifier_id) override {} |
| 21 void UpdatePlatformContextMenu(StatusIconMenuModel* menu) override {} | 23 void UpdatePlatformContextMenu(StatusIconMenuModel* menu) override {} |
| 22 }; | 24 }; |
| 23 | 25 |
| 24 class TestStatusTray : public StatusTray { | 26 class TestStatusTray : public StatusTray { |
| 25 public: | 27 public: |
| 26 StatusIcon* CreatePlatformStatusIcon( | 28 StatusIcon* CreatePlatformStatusIcon( |
| 27 StatusIconType type, | 29 StatusIconType type, |
| 28 const gfx::ImageSkia& image, | 30 const gfx::ImageSkia& image, |
| 29 const base::string16& tool_tip) override { | 31 const base::string16& tool_tip) override { |
| 30 return new MockStatusIcon(); | 32 return new MockStatusIcon(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 47 TEST(StatusTrayTest, CreateRemove) { | 49 TEST(StatusTrayTest, CreateRemove) { |
| 48 TestStatusTray tray; | 50 TestStatusTray tray; |
| 49 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 51 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 50 gfx::ImageSkia* image = rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON); | 52 gfx::ImageSkia* image = rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON); |
| 51 StatusIcon* icon = tray.CreateStatusIcon( | 53 StatusIcon* icon = tray.CreateStatusIcon( |
| 52 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip")); | 54 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip")); |
| 53 EXPECT_EQ(1U, tray.GetStatusIconsForTest().size()); | 55 EXPECT_EQ(1U, tray.GetStatusIconsForTest().size()); |
| 54 tray.RemoveStatusIcon(icon); | 56 tray.RemoveStatusIcon(icon); |
| 55 EXPECT_EQ(0U, tray.GetStatusIconsForTest().size()); | 57 EXPECT_EQ(0U, tray.GetStatusIconsForTest().size()); |
| 56 } | 58 } |
| OLD | NEW |