OLD | NEW |
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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 save_package->title_ = kSuggestedSaveNames[i].page_title; | 401 save_package->title_ = kSuggestedSaveNames[i].page_title; |
402 | 402 |
403 base::FilePath save_name = save_package->GetSuggestedNameForSaveAs( | 403 base::FilePath save_name = save_package->GetSuggestedNameForSaveAs( |
404 kSuggestedSaveNames[i].ensure_html_extension, | 404 kSuggestedSaveNames[i].ensure_html_extension, |
405 std::string(), std::string()); | 405 std::string(), std::string()); |
406 EXPECT_EQ(kSuggestedSaveNames[i].expected_name, save_name.value()) << | 406 EXPECT_EQ(kSuggestedSaveNames[i].expected_name, save_name.value()) << |
407 "Test case " << i; | 407 "Test case " << i; |
408 } | 408 } |
409 } | 409 } |
410 | 410 |
411 static const base::FilePath::CharType* kTestDir = | |
412 FILE_PATH_LITERAL("save_page"); | |
413 | |
414 // GetUrlToBeSaved method should return correct url to be saved. | 411 // GetUrlToBeSaved method should return correct url to be saved. |
415 TEST_F(SavePackageTest, TestGetUrlToBeSaved) { | 412 TEST_F(SavePackageTest, TestGetUrlToBeSaved) { |
416 base::FilePath file_name(FILE_PATH_LITERAL("a.htm")); | 413 GURL url = net::URLRequestMockHTTPJob::GetMockUrl("save_page/a.htm"); |
417 GURL url = net::URLRequestMockHTTPJob::GetMockUrl( | |
418 base::FilePath(kTestDir).Append(file_name)); | |
419 NavigateAndCommit(url); | 414 NavigateAndCommit(url); |
420 EXPECT_EQ(url, GetUrlToBeSaved()); | 415 EXPECT_EQ(url, GetUrlToBeSaved()); |
421 } | 416 } |
422 | 417 |
423 // GetUrlToBeSaved method sould return actual url to be saved, | 418 // GetUrlToBeSaved method sould return actual url to be saved, |
424 // instead of the displayed url used to view source of a page. | 419 // instead of the displayed url used to view source of a page. |
425 // Ex:GetUrlToBeSaved method should return http://www.google.com | 420 // Ex:GetUrlToBeSaved method should return http://www.google.com |
426 // when user types view-source:http://www.google.com | 421 // when user types view-source:http://www.google.com |
427 TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) { | 422 TEST_F(SavePackageTest, TestGetUrlToBeSavedViewSource) { |
428 base::FilePath file_name(FILE_PATH_LITERAL("a.htm")); | 423 GURL mock_url = net::URLRequestMockHTTPJob::GetMockUrl("save_page/a.htm"); |
429 GURL mock_url = net::URLRequestMockHTTPJob::GetMockUrl( | |
430 base::FilePath(kTestDir).Append(file_name)); | |
431 GURL view_source_url = | 424 GURL view_source_url = |
432 GURL(kViewSourceScheme + std::string(":") + mock_url.spec()); | 425 GURL(kViewSourceScheme + std::string(":") + mock_url.spec()); |
433 GURL actual_url = net::URLRequestMockHTTPJob::GetMockUrl( | 426 GURL actual_url = net::URLRequestMockHTTPJob::GetMockUrl("save_page/a.htm"); |
434 base::FilePath(kTestDir).Append(file_name)); | |
435 NavigateAndCommit(view_source_url); | 427 NavigateAndCommit(view_source_url); |
436 EXPECT_EQ(actual_url, GetUrlToBeSaved()); | 428 EXPECT_EQ(actual_url, GetUrlToBeSaved()); |
437 EXPECT_EQ(view_source_url, contents()->GetLastCommittedURL()); | 429 EXPECT_EQ(view_source_url, contents()->GetLastCommittedURL()); |
438 } | 430 } |
439 | 431 |
440 } // namespace content | 432 } // namespace content |
OLD | NEW |