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

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

Issue 541743002: Move url_request_mock_http_job to net/test/url_request/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 3 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 19 matching lines...) Expand all
30 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
33 #include "chrome/test/base/in_process_browser_test.h" 33 #include "chrome/test/base/in_process_browser_test.h"
34 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
35 #include "content/public/browser/download_item.h" 35 #include "content/public/browser/download_item.h"
36 #include "content/public/browser/download_manager.h" 36 #include "content/public/browser/download_manager.h"
37 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
38 #include "content/public/browser/notification_types.h" 38 #include "content/public/browser/notification_types.h"
39 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
40 #include "content/public/common/url_constants.h"
40 #include "content/public/test/test_utils.h" 41 #include "content/public/test/test_utils.h"
41 #include "content/test/net/url_request_mock_http_job.h" 42 #include "net/test/url_request/url_request_mock_http_job.h"
42 #include "testing/gtest/include/gtest/gtest.h" 43 #include "testing/gtest/include/gtest/gtest.h"
43 44
44 using content::BrowserContext; 45 using content::BrowserContext;
45 using content::BrowserThread; 46 using content::BrowserThread;
46 using content::DownloadItem; 47 using content::DownloadItem;
47 using content::DownloadManager; 48 using content::DownloadManager;
48 using content::URLRequestMockHTTPJob;
49 using content::WebContents; 49 using content::WebContents;
50 using net::URLRequestMockHTTPJob;
50 51
51 namespace { 52 namespace {
52 53
53 // Waits for an item record in the downloads database to match |filter|. See 54 // Waits for an item record in the downloads database to match |filter|. See
54 // DownloadStoredProperly() below for an example filter. 55 // DownloadStoredProperly() below for an example filter.
55 class DownloadPersistedObserver : public DownloadHistory::Observer { 56 class DownloadPersistedObserver : public DownloadHistory::Observer {
56 public: 57 public:
57 typedef base::Callback<bool( 58 typedef base::Callback<bool(
58 DownloadItem* item, 59 DownloadItem* item,
59 const history::DownloadRow&)> PersistedFilter; 60 const history::DownloadRow&)> PersistedFilter;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 493 }
493 494
494 // Disabled on Windows due to flakiness. http://crbug.com/162323 495 // Disabled on Windows due to flakiness. http://crbug.com/162323
495 #if defined(OS_WIN) 496 #if defined(OS_WIN)
496 #define MAYBE_SaveViewSourceHTMLOnly DISABLED_SaveViewSourceHTMLOnly 497 #define MAYBE_SaveViewSourceHTMLOnly DISABLED_SaveViewSourceHTMLOnly
497 #else 498 #else
498 #define MAYBE_SaveViewSourceHTMLOnly SaveViewSourceHTMLOnly 499 #define MAYBE_SaveViewSourceHTMLOnly SaveViewSourceHTMLOnly
499 #endif 500 #endif
500 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveViewSourceHTMLOnly) { 501 IN_PROC_BROWSER_TEST_F(SavePageBrowserTest, MAYBE_SaveViewSourceHTMLOnly) {
501 base::FilePath file_name(FILE_PATH_LITERAL("a.htm")); 502 base::FilePath file_name(FILE_PATH_LITERAL("a.htm"));
502 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl( 503 GURL mock_url = URLRequestMockHTTPJob::GetMockUrl(
503 base::FilePath(kTestDir).Append(file_name)); 504 base::FilePath(kTestDir).Append(file_name));
505 GURL view_source_url =
506 GURL(content::kViewSourceScheme + std::string(":") + mock_url.spec());
504 GURL actual_page_url = URLRequestMockHTTPJob::GetMockUrl( 507 GURL actual_page_url = URLRequestMockHTTPJob::GetMockUrl(
505 base::FilePath(kTestDir).Append(file_name)); 508 base::FilePath(kTestDir).Append(file_name));
506 ui_test_utils::NavigateToURL(browser(), view_source_url); 509 ui_test_utils::NavigateToURL(browser(), view_source_url);
507 510
508 base::FilePath full_file_name, dir; 511 base::FilePath full_file_name, dir;
509 GetDestinationPaths("a", &full_file_name, &dir); 512 GetDestinationPaths("a", &full_file_name, &dir);
510 DownloadPersistedObserver persisted(browser()->profile(), base::Bind( 513 DownloadPersistedObserver persisted(browser()->profile(), base::Bind(
511 &DownloadStoredProperly, actual_page_url, full_file_name, 1, 514 &DownloadStoredProperly, actual_page_url, full_file_name, 1,
512 DownloadItem::COMPLETE)); 515 DownloadItem::COMPLETE));
513 scoped_refptr<content::MessageLoopRunner> loop_runner( 516 scoped_refptr<content::MessageLoopRunner> loop_runner(
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 base::FilePath download_dir = DownloadPrefs::FromDownloadManager( 803 base::FilePath download_dir = DownloadPrefs::FromDownloadManager(
801 GetDownloadManager())->DownloadPath(); 804 GetDownloadManager())->DownloadPath();
802 base::FilePath filename = download_dir.AppendASCII("dataurl.txt"); 805 base::FilePath filename = download_dir.AppendASCII("dataurl.txt");
803 ASSERT_TRUE(base::PathExists(filename)); 806 ASSERT_TRUE(base::PathExists(filename));
804 std::string contents; 807 std::string contents;
805 EXPECT_TRUE(base::ReadFileToString(filename, &contents)); 808 EXPECT_TRUE(base::ReadFileToString(filename, &contents));
806 EXPECT_EQ("foo", contents); 809 EXPECT_EQ("foo", contents);
807 } 810 }
808 811
809 } // namespace 812 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/errorpage_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698