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

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

Issue 7277073: Support for adding save page download items into downloads history. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
« no previous file with comments | « chrome/browser/download/save_package.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/save_page_browsertest.cc
===================================================================
--- chrome/browser/download/save_page_browsertest.cc (revision 91326)
+++ chrome/browser/download/save_page_browsertest.cc (working copy)
@@ -7,7 +7,11 @@
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/download/download_history.h"
#include "chrome/browser/download/download_item.h"
+#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/history/download_history_info.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/download/download_tab_helper.h"
@@ -73,6 +77,43 @@
#endif
}
+ void QueryDownloadHistory() {
+ DownloadManager* download_manager =
+ browser()->profile()->GetDownloadManager();
+ ASSERT_TRUE(download_manager);
+
+ // Query the history system.
+ download_manager->download_history()->Load(
+ NewCallback(this,
+ &SavePageBrowserTest::OnQueryDownloadEntriesComplete));
+
+ // Run message loop until a quit message is sent from
+ // OnQueryDownloadEntriesComplete().
+ ui_test_utils::RunMessageLoop();
+ }
+
+ void OnQueryDownloadEntriesComplete(
+ std::vector<DownloadHistoryInfo>* entries) {
+ // Make a copy of the URLs returned by the history system.
+ history_urls_.clear();
+ for (size_t i = 0; i < entries->size(); ++i) {
+ history_urls_.push_back(entries->at(i).url);
+ }
+
+ // Indicate thet we have received the history and can continue.
+ MessageLoopForUI::current()->Quit();
+ }
+
+ void CheckDownloadHistory(const GURL& url) {
+ QueryDownloadHistory();
+
+ EXPECT_NE(std::find(history_urls_.begin(), history_urls_.end(), url),
+ history_urls_.end());
Randy Smith (Not in Mondays) 2011/07/06 20:04:04 I'm inclined to think that we should have a lot mo
+ }
+
+ // URLs found in the history.
+ std::vector<GURL> history_urls_;
+
// Path to directory containing test data.
FilePath test_dir_;
@@ -97,6 +138,7 @@
EXPECT_EQ(url, WaitForSavePackageToFinish());
CheckDownloadUI(full_file_name);
+ CheckDownloadHistory(url);
EXPECT_TRUE(file_util::PathExists(full_file_name));
EXPECT_FALSE(file_util::PathExists(dir));
@@ -125,6 +167,7 @@
EXPECT_EQ(actual_page_url, WaitForSavePackageToFinish());
CheckDownloadUI(full_file_name);
+ CheckDownloadHistory(actual_page_url);
EXPECT_TRUE(file_util::PathExists(full_file_name));
EXPECT_FALSE(file_util::PathExists(dir));
@@ -150,6 +193,7 @@
EXPECT_EQ(url, WaitForSavePackageToFinish());
CheckDownloadUI(full_file_name);
+ CheckDownloadHistory(url);
EXPECT_TRUE(file_util::PathExists(full_file_name));
EXPECT_TRUE(file_util::PathExists(dir));
@@ -191,6 +235,7 @@
EXPECT_EQ(url, WaitForSavePackageToFinish());
CheckDownloadUI(full_file_name);
+ CheckDownloadHistory(url);
EXPECT_TRUE(file_util::PathExists(full_file_name));
EXPECT_TRUE(file_util::PathExists(dir));
« no previous file with comments | « chrome/browser/download/save_package.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698