OLD | NEW |
| (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 "app/menus/simple_menu_model.h" | |
6 #include "app/resource_bundle.h" | |
7 #include "base/string_util.h" | |
8 #include "base/utf_string_conversions.h" | |
9 #include "chrome/browser/gtk/status_icons/status_icon_gtk.h" | |
10 #include "chrome/browser/gtk/status_icons/status_tray_gtk.h" | |
11 #include "grit/browser_resources.h" | |
12 #include "grit/theme_resources.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 | |
16 namespace { | |
17 | |
18 class MockStatusIconObserver : public StatusIcon::Observer { | |
19 public: | |
20 MOCK_METHOD0(OnClicked, void()); | |
21 }; | |
22 | |
23 TEST(StatusTrayGtkTest, CreateTray) { | |
24 // Just tests creation/destruction. | |
25 StatusTrayGtk tray; | |
26 } | |
27 | |
28 TEST(StatusTrayGtkTest, CreateIcon) { | |
29 // Create an icon, set the images and tooltip, then shut it down. | |
30 StatusTrayGtk tray; | |
31 StatusIcon* icon = tray.CreateStatusIcon(); | |
32 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
33 IDR_STATUS_TRAY_ICON); | |
34 icon->SetImage(*bitmap); | |
35 icon->SetPressedImage(*bitmap); | |
36 icon->SetToolTip(ASCIIToUTF16("tool tip")); | |
37 menus::SimpleMenuModel* menu = new menus::SimpleMenuModel(NULL); | |
38 menu->AddItem(0, ASCIIToUTF16("foo")); | |
39 icon->SetContextMenu(menu); | |
40 } | |
41 | |
42 TEST(StatusTrayGtkTest, ClickOnIcon) { | |
43 // Create an icon, send a fake click event, make sure observer is called. | |
44 StatusTrayGtk tray; | |
45 StatusIconGtk* icon = static_cast<StatusIconGtk*>(tray.CreateStatusIcon()); | |
46 MockStatusIconObserver observer; | |
47 icon->AddObserver(&observer); | |
48 EXPECT_CALL(observer, OnClicked()); | |
49 // Mimic a click. | |
50 icon->OnClick(NULL); | |
51 icon->RemoveObserver(&observer); | |
52 } | |
53 | |
54 } // namespace | |
OLD | NEW |