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

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 10822030: Move ui_test_utils::RunMessageLoop to test_utils so that it can be reused by content_browsertests. (Closed) Base URL: svn://chrome-svn/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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 DCHECK(hs); 115 DCHECK(hs);
116 hs->QueryDownloads( 116 hs->QueryDownloads(
117 &callback_consumer_, 117 &callback_consumer_,
118 base::Bind(&DownloadsHistoryDataCollector::OnQueryDownloadsComplete, 118 base::Bind(&DownloadsHistoryDataCollector::OnQueryDownloadsComplete,
119 base::Unretained(this))); 119 base::Unretained(this)));
120 120
121 // TODO(rdsmith): Move message loop out of constructor. 121 // TODO(rdsmith): Move message loop out of constructor.
122 // Cannot complete immediately because the history backend runs on a 122 // Cannot complete immediately because the history backend runs on a
123 // separate thread, so we can assume that the RunMessageLoop below will 123 // separate thread, so we can assume that the RunMessageLoop below will
124 // be exited by the Quit in OnQueryDownloadsComplete. 124 // be exited by the Quit in OnQueryDownloadsComplete.
125 ui_test_utils::RunMessageLoop(); 125 content::RunMessageLoop();
126 } 126 }
127 127
128 bool GetDownloadsHistoryEntry(DownloadPersistentStoreInfo* result) { 128 bool GetDownloadsHistoryEntry(DownloadPersistentStoreInfo* result) {
129 DCHECK(result); 129 DCHECK(result);
130 *result = result_; 130 *result = result_;
131 return result_valid_; 131 return result_valid_;
132 } 132 }
133 133
134 private: 134 private:
135 void OnQueryDownloadsComplete( 135 void OnQueryDownloadsComplete(
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 NULL, 1027 NULL,
1028 1); 1028 1);
1029 bool download_assempted; 1029 bool download_assempted;
1030 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( 1030 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
1031 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), 1031 chrome::GetActiveWebContents(browser())->GetRenderViewHost(),
1032 L"", 1032 L"",
1033 L"window.domAutomationController.send(startDownload());", 1033 L"window.domAutomationController.send(startDownload());",
1034 &download_assempted)); 1034 &download_assempted));
1035 ASSERT_TRUE(download_assempted); 1035 ASSERT_TRUE(download_assempted);
1036 observer.WaitForObservation( 1036 observer.WaitForObservation(
1037 base::Bind(&ui_test_utils::RunMessageLoop), 1037 base::Bind(&content::RunMessageLoop),
1038 base::Bind(&MessageLoop::Quit, 1038 base::Bind(&MessageLoop::Quit,
1039 base::Unretained(MessageLoopForUI::current()))); 1039 base::Unretained(MessageLoopForUI::current())));
1040 1040
1041 // Check that we did not download the file. 1041 // Check that we did not download the file.
1042 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1042 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1043 FilePath file_path(DestinationFile(browser(), file)); 1043 FilePath file_path(DestinationFile(browser(), file));
1044 EXPECT_FALSE(file_util::PathExists(file_path)); 1044 EXPECT_FALSE(file_util::PathExists(file_path));
1045 1045
1046 // Check state. 1046 // Check state.
1047 EXPECT_EQ(1, browser()->tab_count()); 1047 EXPECT_EQ(1, browser()->tab_count());
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
2497 GetDownloads(browser(), &download_items); 2497 GetDownloads(browser(), &download_items);
2498 ASSERT_EQ(1u, download_items.size()); 2498 ASSERT_EQ(1u, download_items.size());
2499 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), 2499 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"),
2500 download_items[0]->GetOriginalUrl()); 2500 download_items[0]->GetOriginalUrl());
2501 2501
2502 // Check that the file contains the expected referrer. 2502 // Check that the file contains the expected referrer.
2503 FilePath file(download_items[0]->GetFullPath()); 2503 FilePath file(download_items[0]->GetFullPath());
2504 std::string expected_contents = test_server()->GetURL("").spec(); 2504 std::string expected_contents = test_server()->GetURL("").spec();
2505 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); 2505 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length()));
2506 } 2506 }
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_sanity_browsertest.cc ('k') | chrome/browser/download/download_test_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698