Commit 08a75b49 authored by tfarina@chromium.org's avatar tfarina@chromium.org

notifications: Refactor MockBalloonView into FakeBalloonView.

R=atwilson@chromium.org
TBR=stevenjb@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10831155

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150036 0039d316-1c4b-4281-b951-d872f2087c98
parent c3e0889d
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/string_util.h" #include "base/string_util.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/notifications/fake_balloon_view.h"
#include "chrome/browser/prefs/browser_prefs.h" #include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service.h" #include "chrome/test/base/testing_pref_service.h"
...@@ -52,7 +53,7 @@ Balloon* MockBalloonCollection::MakeBalloon(const Notification& notification, ...@@ -52,7 +53,7 @@ Balloon* MockBalloonCollection::MakeBalloon(const Notification& notification,
Profile* profile) { Profile* profile) {
// Start with a normal balloon but mock out the view. // Start with a normal balloon but mock out the view.
Balloon* balloon = BalloonCollectionImpl::MakeBalloon(notification, profile); Balloon* balloon = BalloonCollectionImpl::MakeBalloon(notification, profile);
balloon->set_view(new MockBalloonView(balloon)); balloon->set_view(new FakeBalloonView(balloon));
balloons_.push_back(balloon); balloons_.push_back(balloon);
return balloon; return balloon;
} }
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/fake_balloon_view.h"
FakeBalloonView::FakeBalloonView(Balloon* balloon)
: balloon_(balloon) {
}
FakeBalloonView::~FakeBalloonView() {
}
void FakeBalloonView::Show(Balloon* balloon) {
}
void FakeBalloonView::Update() {
}
void FakeBalloonView::RepositionToBalloon() {
}
void FakeBalloonView::Close(bool by_user) {
balloon_->OnClose(by_user);
}
gfx::Size FakeBalloonView::GetSize() const {
return balloon_->content_size();
}
BalloonHost* FakeBalloonView::GetHost() const {
return NULL;
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_NOTIFICATIONS_FAKE_BALLOON_VIEW_H_
#define CHROME_BROWSER_NOTIFICATIONS_FAKE_BALLOON_VIEW_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/notifications/balloon.h"
// Test version of a balloon view which doesn't do anything viewable, but does
// know how to close itself the same as a regular BalloonView.
class FakeBalloonView : public BalloonView {
public:
explicit FakeBalloonView(Balloon* balloon);
virtual ~FakeBalloonView();
private:
// Overridden from BalloonView:
virtual void Show(Balloon* balloon) OVERRIDE;
virtual void Update() OVERRIDE;
virtual void RepositionToBalloon() OVERRIDE;
virtual void Close(bool by_user) OVERRIDE;
virtual gfx::Size GetSize() const OVERRIDE;
virtual BalloonHost* GetHost() const OVERRIDE;
// Non-owned pointer.
Balloon* balloon_;
DISALLOW_COPY_AND_ASSIGN(FakeBalloonView);
};
#endif // CHROME_BROWSER_NOTIFICATIONS_FAKE_BALLOON_VIEW_H_
...@@ -17,15 +17,3 @@ std::string MockNotificationDelegate::id() const { ...@@ -17,15 +17,3 @@ std::string MockNotificationDelegate::id() const {
content::RenderViewHost* MockNotificationDelegate::GetRenderViewHost() const { content::RenderViewHost* MockNotificationDelegate::GetRenderViewHost() const {
return NULL; return NULL;
} }
void MockBalloonView::Close(bool by_user) {
balloon_->OnClose(by_user);
}
gfx::Size MockBalloonView::GetSize() const {
return balloon_->content_size();
}
BalloonHost* MockBalloonView::GetHost() const {
return NULL;
}
...@@ -75,25 +75,4 @@ class LoggingNotificationDelegate : public NotificationDelegate { ...@@ -75,25 +75,4 @@ class LoggingNotificationDelegate : public NotificationDelegate {
DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate); DISALLOW_COPY_AND_ASSIGN(LoggingNotificationDelegate);
}; };
// Test version of a balloon view which doesn't do anything
// viewable, but does know how to close itself the same as a regular
// BalloonView.
class MockBalloonView : public BalloonView {
public:
explicit MockBalloonView(Balloon * balloon) :
balloon_(balloon) {}
// BalloonView:
virtual void Show(Balloon* balloon) OVERRIDE {}
virtual void Update() OVERRIDE {}
virtual void RepositionToBalloon() OVERRIDE {}
virtual void Close(bool by_user) OVERRIDE;
virtual gfx::Size GetSize() const OVERRIDE;
virtual BalloonHost* GetHost() const OVERRIDE;
private:
// Non-owned pointer.
Balloon* balloon_;
};
#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_ #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_TEST_UTIL_H_
...@@ -1545,6 +1545,8 @@ ...@@ -1545,6 +1545,8 @@
'browser/notifications/desktop_notification_service_factory.cc', 'browser/notifications/desktop_notification_service_factory.cc',
'browser/notifications/desktop_notification_service_factory.h', 'browser/notifications/desktop_notification_service_factory.h',
'browser/notifications/desktop_notification_service_win.cc', 'browser/notifications/desktop_notification_service_win.cc',
'browser/notifications/fake_balloon_view.cc',
'browser/notifications/fake_balloon_view.h',
'browser/notifications/notification.cc', 'browser/notifications/notification.cc',
'browser/notifications/notification.h', 'browser/notifications/notification.h',
'browser/notifications/notification_delegate.h', 'browser/notifications/notification_delegate.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment