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

Unified Diff: content/test/download_test_observer.cc

Issue 10855116: Move DownloadTestObserver and friends down into content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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: content/test/download_test_observer.cc
diff --git a/chrome/browser/download/download_test_observer.cc b/content/test/download_test_observer.cc
similarity index 85%
rename from chrome/browser/download/download_test_observer.cc
rename to content/test/download_test_observer.cc
index dd98422ce3064ab303920493959e9bb3b34ebf8d..f562ba6cc2a29884fb391068bb8f0fe506cdb577 100644
--- a/chrome/browser/download/download_test_observer.cc
+++ b/content/test/download_test_observer.cc
@@ -2,19 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "content/public/test/download_test_observer.h"
+
#include <vector>
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/stl_util.h"
-#include "chrome/browser/download/chrome_download_manager_delegate.h"
-#include "chrome/browser/download/download_service.h"
-#include "chrome/browser/download/download_service_factory.h"
-#include "chrome/browser/download/download_test_observer.h"
-#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_url_parameters.h"
+#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
using content::DownloadItem;
@@ -47,6 +46,8 @@ void DenyDangerousDownload(scoped_refptr<DownloadManager> download_manager,
} // namespace
+namespace content {
+
DownloadTestObserver::DownloadTestObserver(
DownloadManager* download_manager,
size_t wait_count,
@@ -388,63 +389,4 @@ const content::DownloadUrlParameters::OnStartedCallback
&DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
}
-namespace internal {
-
-// Test ChromeDownloadManagerDelegate that controls whether how file chooser
-// dialogs are handled. By default, file chooser dialogs are disabled.
-class MockFileChooserDownloadManagerDelegate
- : public ChromeDownloadManagerDelegate {
- public:
- explicit MockFileChooserDownloadManagerDelegate(Profile* profile)
- : ChromeDownloadManagerDelegate(profile),
- file_chooser_enabled_(false),
- file_chooser_displayed_(false) {}
-
- void EnableFileChooser(bool enable) {
- file_chooser_enabled_ = enable;
- }
-
- bool TestAndResetDidShowFileChooser() {
- bool did_show = file_chooser_displayed_;
- file_chooser_displayed_ = false;
- return did_show;
- }
-
- private:
- virtual ~MockFileChooserDownloadManagerDelegate() {}
-
- virtual void ChooseDownloadPath(DownloadItem* item,
- const FilePath& suggested_path,
- const FileSelectedCallback&
- callback) OVERRIDE {
- file_chooser_displayed_ = true;
- MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(callback,
- (file_chooser_enabled_ ? suggested_path : FilePath())));
- }
-
- bool file_chooser_enabled_;
- bool file_chooser_displayed_;
-};
-
-} // namespace internal
-
-DownloadTestFileChooserObserver::DownloadTestFileChooserObserver(
- Profile* profile) {
- test_delegate_ =
- new internal::MockFileChooserDownloadManagerDelegate(profile);
- DownloadServiceFactory::GetForProfile(profile)->
- SetDownloadManagerDelegateForTesting(test_delegate_.get());
-}
-
-DownloadTestFileChooserObserver::~DownloadTestFileChooserObserver() {
-}
-
-void DownloadTestFileChooserObserver::EnableFileChooser(bool enable) {
- test_delegate_->EnableFileChooser(enable);
-}
-
-bool DownloadTestFileChooserObserver::TestAndResetDidShowFileChooser() {
- return test_delegate_->TestAndResetDidShowFileChooser();
-}
+} // namespace content
« content/public/test/download_test_observer.h ('K') | « content/public/test/download_test_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698