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 "chrome/browser/ui/views/status_icons/status_tray_win.h" | 5 #include "chrome/browser/ui/views/status_icons/status_tray_win.h" |
6 | 6 |
7 #include <commctrl.h> | 7 #include <commctrl.h> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 TEST(StatusTrayWinTest, CreateIconAndMenu) { | 66 TEST(StatusTrayWinTest, CreateIconAndMenu) { |
67 // Create an icon, set the images, tooltip, and context menu, then shut it | 67 // Create an icon, set the images, tooltip, and context menu, then shut it |
68 // down. | 68 // down. |
69 StatusTrayWin tray; | 69 StatusTrayWin tray; |
70 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 70 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
71 gfx::ImageSkia* image = rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON); | 71 gfx::ImageSkia* image = rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON); |
72 StatusIcon* icon = tray.CreateStatusIcon( | 72 StatusIcon* icon = tray.CreateStatusIcon( |
73 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip")); | 73 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip")); |
74 icon->SetPressedImage(*image); | |
75 scoped_ptr<StatusIconMenuModel> menu(new StatusIconMenuModel(NULL)); | 74 scoped_ptr<StatusIconMenuModel> menu(new StatusIconMenuModel(NULL)); |
76 menu->AddItem(0, L"foo"); | 75 menu->AddItem(0, L"foo"); |
77 icon->SetContextMenu(menu.Pass()); | 76 icon->SetContextMenu(menu.Pass()); |
78 } | 77 } |
79 | 78 |
80 #if !defined(USE_AURA) // http://crbug.com/156370 | 79 #if !defined(USE_AURA) // http://crbug.com/156370 |
81 TEST(StatusTrayWinTest, ClickOnIcon) { | 80 TEST(StatusTrayWinTest, ClickOnIcon) { |
82 // Create an icon, send a fake click event, make sure observer is called. | 81 // Create an icon, send a fake click event, make sure observer is called. |
83 StatusTrayWin tray; | 82 StatusTrayWin tray; |
84 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 83 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 StatusIconWin* icon = static_cast<StatusIconWin*>(tray.CreateStatusIcon( | 140 StatusIconWin* icon = static_cast<StatusIconWin*>(tray.CreateStatusIcon( |
142 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip"))); | 141 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip"))); |
143 | 142 |
144 icon->ForceVisible(); | 143 icon->ForceVisible(); |
145 // |proxy| is owned by |tray|, and |tray| lives to the end of the scope, | 144 // |proxy| is owned by |tray|, and |tray| lives to the end of the scope, |
146 // so calling methods on |proxy| is safe. | 145 // so calling methods on |proxy| is safe. |
147 EXPECT_TRUE(proxy->enqueue_called()); | 146 EXPECT_TRUE(proxy->enqueue_called()); |
148 EXPECT_EQ(proxy->window(), icon->window()); | 147 EXPECT_EQ(proxy->window(), icon->window()); |
149 EXPECT_EQ(proxy->icon_id(), icon->icon_id()); | 148 EXPECT_EQ(proxy->icon_id(), icon->icon_id()); |
150 } | 149 } |
OLD | NEW |