Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/string_util.h" | |
| 6 #include "base/utf_string_conversions.h" | |
| 7 #include "chrome/browser/ui/views/status_icons/status_icon_chromeos.h" | |
| 8 #include "chrome/browser/ui/views/status_icons/status_tray_chromeos.h" | |
| 9 #include "grit/theme_resources.h" | |
| 10 #include "testing/gmock/include/gmock/gmock.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | |
| 12 #include "ui/base/models/simple_menu_model.h" | |
| 13 #include "ui/base/resource/resource_bundle.h" | |
| 14 | |
| 15 class SkBitmap; | |
| 16 | |
| 17 class MockStatusIconObserver : public StatusIcon::Observer { | |
| 18 public: | |
| 19 MOCK_METHOD0(OnClicked, void()); | |
| 20 }; | |
| 21 | |
| 22 TEST(StatusTrayChromeOSTest, CreateTray) { | |
| 23 // Just tests creation/destruction. | |
| 24 StatusTrayChromeOS tray; | |
| 25 } | |
| 26 | |
| 27 TEST(StatusTrayChromeOSTest, CreateIconAndMenu) { | |
| 28 // Create an icon, set the images, tooltip, and context menu, then shut it | |
| 29 // down. | |
| 30 StatusTrayChromeOS 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 ui::SimpleMenuModel* menu = new ui::SimpleMenuModel(NULL); | |
| 38 menu->AddItem(0, ASCIIToUTF16("foo")); | |
| 39 icon->SetContextMenu(menu); | |
| 40 } | |
|
Andrew T Wilson (Slow)
2011/11/14 23:46:03
Is there any way for us to test that the appropria
Leandro GraciĆ” Gil
2011/11/15 22:23:31
Good point. I guess we need to make this a browser
| |
| 41 | |
| 42 TEST(StatusTrayChromeOSTest, ClickOnIcon) { | |
| 43 // Create an icon, send a fake click event, make sure observer is called. | |
| 44 StatusTrayChromeOS tray; | |
| 45 StatusIconChromeOS* icon = | |
| 46 static_cast<StatusIconChromeOS*>(tray.CreateStatusIcon()); | |
| 47 MockStatusIconObserver observer; | |
| 48 icon->AddObserver(&observer); | |
| 49 EXPECT_CALL(observer, OnClicked()); | |
| 50 // Mimic a click. | |
| 51 icon->Clicked(); | |
| 52 icon->RemoveObserver(&observer); | |
| 53 } | |
| 54 | |
| OLD | NEW |