This source file includes following definitions.
- SetImage
- SetPressedImage
- SetToolTip
- UpdatePlatformContextMenu
- DisplayBalloon
- TEST
- TEST
#include "chrome/browser/status_icons/status_icon.h"
#include "base/compiler_specific.h"
#include "chrome/browser/status_icons/status_icon_observer.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
class MockStatusIconObserver : public StatusIconObserver {
public:
MOCK_METHOD0(OnStatusIconClicked, void());
};
class TestStatusIcon : public StatusIcon {
public:
TestStatusIcon() {}
virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE {}
virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE {}
virtual void SetToolTip(const base::string16& tool_tip) OVERRIDE {}
virtual void UpdatePlatformContextMenu(
StatusIconMenuModel* menu) OVERRIDE {}
virtual void DisplayBalloon(const gfx::ImageSkia& icon,
const base::string16& title,
const base::string16& contents) OVERRIDE {}
};
TEST(StatusIconTest, ObserverAdd) {
TestStatusIcon icon;
MockStatusIconObserver observer, observer2;
EXPECT_CALL(observer, OnStatusIconClicked()).Times(2);
EXPECT_CALL(observer2, OnStatusIconClicked());
icon.AddObserver(&observer);
icon.DispatchClickEvent();
icon.AddObserver(&observer2);
icon.DispatchClickEvent();
icon.RemoveObserver(&observer);
icon.RemoveObserver(&observer2);
}
TEST(StatusIconTest, ObserverRemove) {
TestStatusIcon icon;
MockStatusIconObserver observer;
EXPECT_CALL(observer, OnStatusIconClicked());
icon.AddObserver(&observer);
icon.DispatchClickEvent();
icon.RemoveObserver(&observer);
icon.DispatchClickEvent();
}