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

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: fixing gyp problems in the bots that led to reverting. 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/chromeos/frame/browser_view.h"
8 #include "chrome/browser/chromeos/status/status_area_button.h"
9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/browser/ui/views/status_icons/status_icon_chromeos.h"
11 #include "chrome/browser/ui/views/status_icons/status_tray_chromeos.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "grit/theme_resources.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/base/models/simple_menu_model.h"
17 #include "ui/base/resource/resource_bundle.h"
18
19 class SkBitmap;
20
21 class MockStatusIconObserver : public StatusIcon::Observer {
22 public:
23 MOCK_METHOD0(OnClicked, void());
24 };
25
26 // Using a browser test since in ChromeOS the status icons are added
27 // to the browser windows. If there is no browser nothing is tested.
28 class StatusTrayChromeOSBrowserTest : public InProcessBrowserTest {};
29
30 IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, CreateTray) {
31 // Just tests creation/destruction.
32 StatusTrayChromeOS tray;
33 }
34
35 IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, CreateIconAndMenu) {
36 // Create an icon, set the images, tooltip, and context menu, then shut it
37 // down.
38 StatusTrayChromeOS tray;
39 StatusIcon* icon = tray.CreateStatusIcon();
40 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
41 IDR_STATUS_TRAY_ICON);
42 icon->SetImage(*bitmap);
43 icon->SetPressedImage(*bitmap);
44 icon->SetToolTip(ASCIIToUTF16("tool tip"));
45 ui::SimpleMenuModel* menu = new ui::SimpleMenuModel(NULL);
46 menu->AddItem(0, ASCIIToUTF16("foo"));
47 icon->SetContextMenu(menu);
48
49 Browser* browser = BrowserList::GetLastActive();
50 ASSERT_TRUE(browser != NULL);
51 chromeos::BrowserView* browser_view =
52 chromeos::BrowserView::GetBrowserViewForBrowser(browser);
53 ASSERT_TRUE(browser_view != NULL);
54 StatusAreaButton* button =
55 static_cast<StatusIconChromeOS*>(icon)->GetButtonForBrowser(browser);
56 ASSERT_TRUE(button != NULL);
57 ASSERT_TRUE(browser_view->ContainsButton(button));
58 }
59
60 IN_PROC_BROWSER_TEST_F(StatusTrayChromeOSBrowserTest, ClickOnIcon) {
61 // Create an icon, send a fake click event, make sure observer is called.
62 StatusTrayChromeOS tray;
63 StatusIconChromeOS* icon =
64 static_cast<StatusIconChromeOS*>(tray.CreateStatusIcon());
65 MockStatusIconObserver observer;
66 icon->AddObserver(&observer);
67 EXPECT_CALL(observer, OnClicked());
68
69 // Send a click.
70 Browser* browser = BrowserList::GetLastActive();
71 ASSERT_TRUE(browser != NULL);
72 StatusAreaButton* button =
73 static_cast<StatusIconChromeOS*>(icon)->GetButtonForBrowser(browser);
74 ASSERT_TRUE(button != NULL);
75 button->Activate();
76 icon->RemoveObserver(&observer);
77 }
78
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/status_icons/status_tray_chromeos.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698