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

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

Issue 275011: Make the multiple download request dialog an infobar.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 0)
+++ chrome/browser/download/download_request_infobar_delegate_unittest.cc (revision 0)
@@ -0,0 +1,66 @@
+// Copyright (c) 2009 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/download/download_request_infobar_delegate.h"
+#include "chrome/browser/download/download_request_manager.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class MockTabDownloadState : public DownloadRequestManager::TabDownloadState {
+ public:
+ MockTabDownloadState() : responded_(false), accepted_(false) {
+ }
+
+ virtual ~MockTabDownloadState() {
+ EXPECT_TRUE(responded_);
+ }
+
+ virtual void Accept() {
+ EXPECT_FALSE(responded_);
+ responded_ = true;
+ accepted_ = true;
+ }
+
+ virtual void Cancel() {
+ EXPECT_FALSE(responded_);
+ responded_ = true;
+ accepted_ = false;
+ }
+
+ bool responded() {
+ return responded_;
+ }
+
+ bool accepted() {
+ return responded_ && accepted_;
+ }
+
+ private:
+ // True if we have gotten some sort of response.
+ bool responded_;
+
+ // True if we have gotten a Accept response. Meaningless if |responded_| is
+ // not true.
+ bool accepted_;
+};
+
+TEST(DownloadRequestInfobar, AcceptTest) {
+ MockTabDownloadState state;
+ DownloadRequestInfoBarDelegate infobar(NULL, &state);
+ infobar.Accept();
+ EXPECT_TRUE(state.accepted());
+}
+
+TEST(DownloadRequestInfobar, CancelTest) {
+ MockTabDownloadState state;
+ DownloadRequestInfoBarDelegate infobar(NULL, &state);
+ infobar.Cancel();
+ EXPECT_FALSE(state.accepted());
+}
+
+TEST(DownloadRequestInfobar, CloseTest) {
+ MockTabDownloadState state;
+ DownloadRequestInfoBarDelegate infobar(NULL, &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_request_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698