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

Unified Diff: chrome/browser/download/download_request_infobar_delegate_unittest.cc

Issue 6249010: Cleanup: de-inline a bunch of classes, rename and move "PluginInstaller" to "... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_request_infobar_delegate_unittest.cc
===================================================================
--- chrome/browser/download/download_request_infobar_delegate_unittest.cc (revision 72158)
+++ chrome/browser/download/download_request_infobar_delegate_unittest.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,36 +6,27 @@
#include "chrome/browser/download/download_request_limiter.h"
#include "testing/gtest/include/gtest/gtest.h"
+// MockTabDownloadState -------------------------------------------------------
+
class MockTabDownloadState : public DownloadRequestLimiter::TabDownloadState {
public:
- MockTabDownloadState() : responded_(false), accepted_(false) {
- }
+ MockTabDownloadState();
+ virtual ~MockTabDownloadState();
- virtual ~MockTabDownloadState() {
- EXPECT_TRUE(responded_);
- }
+ // DownloadRequestLimiter::TabDownloadState
+ virtual void Cancel();
+ virtual void Accept();
- virtual void Accept() {
- EXPECT_FALSE(responded_);
- responded_ = true;
- accepted_ = true;
+ ConfirmInfoBarDelegate* infobar() {
+ return infobar_->AsConfirmInfoBarDelegate();
}
+ bool responded() const { return responded_; }
+ bool accepted() const { return accepted_; }
- virtual void Cancel() {
- EXPECT_FALSE(responded_);
- responded_ = true;
- accepted_ = false;
- }
+ private:
+ // The actual infobar delegate we're listening to.
+ scoped_ptr<InfoBarDelegate> infobar_;
- bool responded() {
- return responded_;
- }
-
- bool accepted() {
- return responded_ && accepted_;
- }
-
- private:
// True if we have gotten some sort of response.
bool responded_;
@@ -44,23 +35,44 @@
bool accepted_;
};
-TEST(DownloadRequestInfobar, AcceptTest) {
+MockTabDownloadState::MockTabDownloadState()
+ : responded_(false), accepted_(false) {
+ infobar_.reset(new DownloadRequestInfoBarDelegate(NULL, this));
+}
+
+MockTabDownloadState::~MockTabDownloadState() {
+ EXPECT_TRUE(responded_);
+}
+
+void MockTabDownloadState::Cancel() {
+ EXPECT_FALSE(responded_);
+ responded_ = true;
+ accepted_ = false;
+}
+
+void MockTabDownloadState::Accept() {
+ EXPECT_FALSE(responded_);
+ responded_ = true;
+ accepted_ = true;
+}
+
+
+// Tests ----------------------------------------------------------------------
+
+TEST(DownloadRequestInfobarDelegate, AcceptTest) {
MockTabDownloadState state;
- DownloadRequestInfoBarDelegate infobar(NULL, &state);
- infobar.Accept();
+ state.infobar()->Accept();
EXPECT_TRUE(state.accepted());
}
-TEST(DownloadRequestInfobar, CancelTest) {
+TEST(DownloadRequestInfobarDelegate, CancelTest) {
MockTabDownloadState state;
- DownloadRequestInfoBarDelegate infobar(NULL, &state);
- infobar.Cancel();
+ state.infobar()->Cancel();
EXPECT_FALSE(state.accepted());
}
-TEST(DownloadRequestInfobar, CloseTest) {
+TEST(DownloadRequestInfobarDelegate, CloseTest) {
MockTabDownloadState state;
- DownloadRequestInfoBarDelegate infobar(NULL, &state);
- infobar.InfoBarClosed();
+ state.infobar()->InfoBarClosed();
EXPECT_FALSE(state.accepted());
}
« no previous file with comments | « chrome/browser/download/download_request_infobar_delegate.cc ('k') | chrome/browser/download/download_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698