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

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

Issue 8351004: Add an extra argument to the DisplayBalloon method to support custom notification icons. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing argument order as suggested. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/status_icons/status_icon.h" 6 #include "chrome/browser/status_icons/status_icon.h"
6 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 class MockStatusIconObserver : public StatusIcon::Observer { 10 class MockStatusIconObserver : public StatusIcon::Observer {
10 public: 11 public:
11 MOCK_METHOD0(OnClicked, void()); 12 MOCK_METHOD0(OnClicked, void());
12 }; 13 };
13 14
14 // Define pure virtual functions so we can test base class functionality. 15 // Define pure virtual functions so we can test base class functionality.
15 class TestStatusIcon : public StatusIcon { 16 class TestStatusIcon : public StatusIcon {
16 public: 17 public:
17 TestStatusIcon() {} 18 TestStatusIcon() {}
18 virtual void SetImage(const SkBitmap& image) {} 19 virtual void SetImage(const SkBitmap& image) OVERRIDE {}
19 virtual void SetPressedImage(const SkBitmap& image) {} 20 virtual void SetPressedImage(const SkBitmap& image) OVERRIDE {}
20 virtual void SetToolTip(const string16& tool_tip) {} 21 virtual void SetToolTip(const string16& tool_tip) OVERRIDE {}
21 virtual void UpdatePlatformContextMenu(ui::MenuModel* menu) {} 22 virtual void UpdatePlatformContextMenu(ui::MenuModel* menu) OVERRIDE {}
22 virtual void DisplayBalloon(const string16& title, 23 virtual void DisplayBalloon(const SkBitmap& icon,
23 const string16& contents) {} 24 const string16& title,
25 const string16& contents) OVERRIDE {}
24 }; 26 };
25 27
26 TEST(StatusIconTest, ObserverAdd) { 28 TEST(StatusIconTest, ObserverAdd) {
27 // Make sure that observers are invoked when we click items. 29 // Make sure that observers are invoked when we click items.
28 TestStatusIcon icon; 30 TestStatusIcon icon;
29 MockStatusIconObserver observer, observer2; 31 MockStatusIconObserver observer, observer2;
30 EXPECT_CALL(observer, OnClicked()).Times(2); 32 EXPECT_CALL(observer, OnClicked()).Times(2);
31 EXPECT_CALL(observer2, OnClicked()); 33 EXPECT_CALL(observer2, OnClicked());
32 icon.AddObserver(&observer); 34 icon.AddObserver(&observer);
33 icon.DispatchClickEvent(); 35 icon.DispatchClickEvent();
34 icon.AddObserver(&observer2); 36 icon.AddObserver(&observer2);
35 icon.DispatchClickEvent(); 37 icon.DispatchClickEvent();
36 icon.RemoveObserver(&observer); 38 icon.RemoveObserver(&observer);
37 icon.RemoveObserver(&observer2); 39 icon.RemoveObserver(&observer2);
38 } 40 }
39 41
40 TEST(StatusIconTest, ObserverRemove) { 42 TEST(StatusIconTest, ObserverRemove) {
41 // Make sure that observers are no longer invoked after they are removed. 43 // Make sure that observers are no longer invoked after they are removed.
42 TestStatusIcon icon; 44 TestStatusIcon icon;
43 MockStatusIconObserver observer; 45 MockStatusIconObserver observer;
44 EXPECT_CALL(observer, OnClicked()); 46 EXPECT_CALL(observer, OnClicked());
45 icon.AddObserver(&observer); 47 icon.AddObserver(&observer);
46 icon.DispatchClickEvent(); 48 icon.DispatchClickEvent();
47 icon.RemoveObserver(&observer); 49 icon.RemoveObserver(&observer);
48 icon.DispatchClickEvent(); 50 icon.DispatchClickEvent();
49 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698