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

Side by Side Diff: content/browser/download/save_package_unittest.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: Fixed a few compile errors 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 <string> 5 #include <string>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/browser/download/save_package.h" 12 #include "content/browser/download/save_package.h"
13 #include "content/test/net/url_request_mock_http_job.h"
14 #include "content/test/test_render_view_host.h" 13 #include "content/test/test_render_view_host.h"
15 #include "content/test/test_web_contents.h" 14 #include "content/test/test_web_contents.h"
15 #include "net/test/url_request/url_request_mock_http_job.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace content { 19 namespace content {
20 20
21 #define FPL FILE_PATH_LITERAL 21 #define FPL FILE_PATH_LITERAL
22 #define HTML_EXTENSION ".html" 22 #define HTML_EXTENSION ".html"
23 #if defined(OS_WIN) 23 #if defined(OS_WIN)
24 #define FPL_HTML_EXTENSION L".html" 24 #define FPL_HTML_EXTENSION L".html"
25 #else 25 #else
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 "Test case " << i; 407 "Test case " << i;
408 } 408 }
409 } 409 }
410 410
411 static const base::FilePath::CharType* kTestDir = 411 static const base::FilePath::CharType* kTestDir =
412 FILE_PATH_LITERAL("save_page"); 412 FILE_PATH_LITERAL("save_page");
413 413
414 // GetUrlToBeSaved method should return correct url to be saved. 414 // GetUrlToBeSaved method should return correct url to be saved.
415 TEST_F(SavePackageTest, TestGetUrlToBeSaved) { 415 TEST_F(SavePackageTest, TestGetUrlToBeSaved) {
416 base::FilePath file_name(FILE_PATH_LITERAL("a.htm")); 416 base::FilePath file_name(FILE_PATH_LITERAL("a.htm"));
417 GURL url = URLRequestMockHTTPJob::GetMockUrl( 417 GURL url = net::URLRequestMockHTTPJob::GetMockUrl(
418 base::FilePath(kTestDir).Append(file_name)); 418 base::FilePath(kTestDir).Append(file_name));
419 NavigateAndCommit(url); 419 NavigateAndCommit(url);
420 EXPECT_EQ(url, GetUrlToBeSaved()); 420 EXPECT_EQ(url, GetUrlToBeSaved());
421 } 421 }
422 422
423 // GetUrlToBeSaved method sould return actual url to be saved, 423 // GetUrlToBeSaved method sould return actual url to be saved,
424 // instead of the displayed url used to view source of a page. 424 // instead of the displayed url used to view source of a page.
425 // Ex:GetUrlToBeSaved method should return http://www.google.com 425 // Ex:GetUrlToBeSaved method should return http://www.google.com
426 // when user types view-source:http://www.google.com 426 // when user types view-source:http://www.google.com
427 TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) { 427 TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) {
428 base::FilePath file_name(FILE_PATH_LITERAL("a.htm")); 428 base::FilePath file_name(FILE_PATH_LITERAL("a.htm"));
429 GURL view_source_url = URLRequestMockHTTPJob::GetMockViewSourceUrl( 429 GURL view_source_url = net::URLRequestMockHTTPJob::GetMockViewSourceUrl(
430 base::FilePath(kTestDir).Append(file_name)); 430 base::FilePath(kTestDir).Append(file_name));
431 GURL actual_url = URLRequestMockHTTPJob::GetMockUrl( 431 GURL actual_url = net::URLRequestMockHTTPJob::GetMockUrl(
432 base::FilePath(kTestDir).Append(file_name)); 432 base::FilePath(kTestDir).Append(file_name));
433 NavigateAndCommit(view_source_url); 433 NavigateAndCommit(view_source_url);
434 EXPECT_EQ(actual_url, GetUrlToBeSaved()); 434 EXPECT_EQ(actual_url, GetUrlToBeSaved());
435 EXPECT_EQ(view_source_url, contents()->GetLastCommittedURL()); 435 EXPECT_EQ(view_source_url, contents()->GetLastCommittedURL());
436 } 436 }
437 437
438 } // namespace content 438 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698