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

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

Issue 661454: Initial implementation of status tray functionality (mac-only, currently). (Closed)
Patch Set: more changes per review feedback Created 10 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
« no previous file with comments | « chrome/browser/status_icons/status_tray_manager.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/string_util.h"
6 #include "chrome/browser/status_icons/status_icon.h"
7 #include "chrome/browser/status_icons/status_tray.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 using testing::Return;
12
13 class MockStatusIcon : public StatusIcon {
14 virtual void SetImage(const SkBitmap& image) {}
15 virtual void SetToolTip(const string16& tool_tip) {}
16 virtual void AddObserver(StatusIcon::StatusIconObserver* observer) {}
17 virtual void RemoveObserver(StatusIcon::StatusIconObserver* observer) {}
18 };
19
20 class TestStatusIconFactory : public StatusIconFactory {
21 public:
22 MOCK_METHOD0(CreateIcon, StatusIcon*());
23 };
24
25 TEST(StatusTrayTest, Create) {
26 // Check for creation and leaks.
27 TestStatusIconFactory* factory = new TestStatusIconFactory();
28 StatusTray tray(factory);
29 EXPECT_CALL(*factory, CreateIcon()).WillOnce(Return(new MockStatusIcon()));
30 tray.GetStatusIcon(ASCIIToUTF16("test"));
31 }
32
33 TEST(StatusTrayTest, GetIconTwice) {
34 TestStatusIconFactory* factory = new TestStatusIconFactory();
35 StatusTray tray(factory);
36 string16 id = ASCIIToUTF16("test");
37 // We should not try to create a new icon if we get the same ID twice.
38 EXPECT_CALL(*factory, CreateIcon()).WillOnce(Return(new MockStatusIcon()));
39 StatusIcon* icon = tray.GetStatusIcon(id);
40 EXPECT_EQ(icon, tray.GetStatusIcon(id));
41 }
42
43 TEST(StatusTrayTest, GetIconAfterRemove) {
44 TestStatusIconFactory* factory = new TestStatusIconFactory();
45 StatusTray tray(factory);
46 string16 id = ASCIIToUTF16("test");
47 EXPECT_CALL(*factory, CreateIcon()).Times(2)
48 .WillOnce(Return(new MockStatusIcon()))
49 .WillOnce(Return(new MockStatusIcon()));
50 StatusIcon* icon = tray.GetStatusIcon(id);
51 EXPECT_EQ(icon, tray.GetStatusIcon(id));
52
53 // If we remove the icon, then we should create a new one the next time in.
54 tray.RemoveStatusIcon(id);
55 tray.GetStatusIcon(id);
56 }
OLDNEW
« no previous file with comments | « chrome/browser/status_icons/status_tray_manager.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698