Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / status_icons / status_tray_gtk_unittest.cc
blob486dcaf7a7e7f463867caf5c7f4d1e59f51db365
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/gtk/status_icons/status_tray_gtk.h"
7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/status_icons/status_icon_menu_model.h"
10 #include "chrome/browser/status_icons/status_icon_observer.h"
11 #include "chrome/browser/ui/gtk/status_icons/status_icon_gtk.h"
12 #include "grit/chrome_unscaled_resources.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/gfx/image/image_skia.h"
18 namespace {
20 class MockStatusIconObserver : public StatusIconObserver {
21 public:
22 MOCK_METHOD0(OnStatusIconClicked, void());
25 TEST(StatusTrayGtkTest, CreateTray) {
26 // Just tests creation/destruction.
27 StatusTrayGtk tray;
30 TEST(StatusTrayGtkTest, CreateIcon) {
31 // Create an icon, set the images and tooltip, then shut it down.
32 StatusTrayGtk tray;
33 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
34 gfx::ImageSkia* image = rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON);
35 StatusIcon* icon = tray.CreateStatusIcon(
36 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip"));
37 icon->SetPressedImage(*image);
38 scoped_ptr<StatusIconMenuModel> menu(new StatusIconMenuModel(NULL));
39 menu->AddItem(0, base::ASCIIToUTF16("foo"));
40 icon->SetContextMenu(menu.Pass());
43 TEST(StatusTrayGtkTest, ClickOnIcon) {
44 // Create an icon, send a fake click event, make sure observer is called.
45 StatusTrayGtk tray;
46 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
47 gfx::ImageSkia* image = rb.GetImageSkiaNamed(IDR_STATUS_TRAY_ICON);
48 StatusIconGtk* icon = static_cast<StatusIconGtk*>(tray.CreateStatusIcon(
49 StatusTray::OTHER_ICON, *image, base::ASCIIToUTF16("tool tip")));
50 MockStatusIconObserver observer;
51 icon->AddObserver(&observer);
52 EXPECT_CALL(observer, OnStatusIconClicked());
53 // Mimic a click.
54 icon->OnClick(NULL);
55 icon->RemoveObserver(&observer);
58 } // namespace