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

Side by Side Diff: chrome/browser/ui/views/status_icons/status_tray_chromeos_browsertest.cc

Issue 8476003: Implement the status tray/icon API for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixes and some gyp fixing. Created 9 years, 1 month 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
(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 "chrome/test/base/in_process_browser_test.h"
10 #include "grit/theme_resources.h"
11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/base/models/simple_menu_model.h"
14 #include "ui/base/resource/resource_bundle.h"
15
16 class SkBitmap;
17
18 class MockStatusIconObserver : public StatusIcon::Observer {
19 public:
20 MOCK_METHOD0(OnClicked, void());
21 };
22
23 // Using a browser test since in ChromeOS the status icons are added
24 // to the browser windows. If there is no browser nothing is tested.
25 class StatusTrayChromeOSBrowserTest : public InProcessBrowserTest {};
26
27 IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, CreateTray) {
28 // Just tests creation/destruction.
29 StatusTrayChromeOS tray;
30 }
31
32 IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, CreateIconAndMenu) {
33 // Create an icon, set the images, tooltip, and context menu, then shut it
34 // down.
35 StatusTrayChromeOS tray;
36 StatusIcon* icon = tray.CreateStatusIcon();
37 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
38 IDR_STATUS_TRAY_ICON);
39 icon->SetImage(*bitmap);
40 icon->SetPressedImage(*bitmap);
41 icon->SetToolTip(ASCIIToUTF16("tool tip"));
42 ui::SimpleMenuModel* menu = new ui::SimpleMenuModel(NULL);
43 menu->AddItem(0, ASCIIToUTF16("foo"));
44 icon->SetContextMenu(menu);
Andrew T Wilson (Slow) 2011/11/16 00:28:54 This is just checking to make sure we don't crash
Leandro Graciá Gil 2011/11/17 16:18:48 I'm not sure about displayed, but we should be abl
45 }
46
47 IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, ClickOnIcon) {
48 // Create an icon, send a fake click event, make sure observer is called.
49 StatusTrayChromeOS tray;
50 StatusIconChromeOS* icon =
51 static_cast<StatusIconChromeOS*>(tray.CreateStatusIcon());
52 MockStatusIconObserver observer;
53 icon->AddObserver(&observer);
54 EXPECT_CALL(observer, OnClicked());
55 // Mimic a click.
56 icon->TestClicked();
Andrew T Wilson (Slow) 2011/11/16 00:28:54 Instead of exposing TestClicked(), is it possible
Leandro Graciá Gil 2011/11/17 16:18:48 I can reverse the way it's done. The button's Acti
57 icon->RemoveObserver(&observer);
58 }
59
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698