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

Side by Side Diff: content/browser/download/save_package_browsertest.cc

Issue 1411073005: Migrating tests to use EmbeddedTestServer (/content) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "content/browser/download/save_package.h" 6 #include "content/browser/download/save_package.h"
7 #include "content/public/test/content_browser_test.h" 7 #include "content/public/test/content_browser_test.h"
8 #include "content/public/test/content_browser_test_utils.h" 8 #include "content/public/test/content_browser_test_utils.h"
9 #include "content/shell/browser/shell.h" 9 #include "content/shell/browser/shell.h"
mmenke 2015/11/03 19:12:57 include embedded_test_server.h
svaldez 2015/11/03 19:33:16 Done.
10 10
11 namespace content { 11 namespace content {
12 12
13 const char kTestFile[] = "files/simple_page.html"; 13 const char kTestFile[] = "/simple_page.html";
14 14
15 class SavePackageBrowserTest : public ContentBrowserTest { 15 class SavePackageBrowserTest : public ContentBrowserTest {
16 protected: 16 protected:
17 void SetUp() override { 17 void SetUp() override {
18 ASSERT_TRUE(save_dir_.CreateUniqueTempDir()); 18 ASSERT_TRUE(save_dir_.CreateUniqueTempDir());
19 ContentBrowserTest::SetUp(); 19 ContentBrowserTest::SetUp();
20 } 20 }
21 21
22 // Returns full paths of destination file and directory. 22 // Returns full paths of destination file and directory.
23 void GetDestinationPaths(const std::string& prefix, 23 void GetDestinationPaths(const std::string& prefix,
24 base::FilePath* full_file_name, 24 base::FilePath* full_file_name,
25 base::FilePath* dir) { 25 base::FilePath* dir) {
26 *full_file_name = save_dir_.path().AppendASCII(prefix + ".htm"); 26 *full_file_name = save_dir_.path().AppendASCII(prefix + ".htm");
27 *dir = save_dir_.path().AppendASCII(prefix + "_files"); 27 *dir = save_dir_.path().AppendASCII(prefix + "_files");
28 } 28 }
29 29
30 // Temporary directory we will save pages to. 30 // Temporary directory we will save pages to.
31 base::ScopedTempDir save_dir_; 31 base::ScopedTempDir save_dir_;
32 }; 32 };
33 33
34 // Create a SavePackage and delete it without calling Init. 34 // Create a SavePackage and delete it without calling Init.
35 // SavePackage dtor has various asserts/checks that should not fire. 35 // SavePackage dtor has various asserts/checks that should not fire.
36 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ImplicitCancel) { 36 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ImplicitCancel) {
37 ASSERT_TRUE(test_server()->Start()); 37 ASSERT_TRUE(embedded_test_server()->Start());
38 GURL url = test_server()->GetURL(kTestFile); 38 GURL url = embedded_test_server()->GetURL(kTestFile);
39 NavigateToURL(shell(), url); 39 NavigateToURL(shell(), url);
40 base::FilePath full_file_name, dir; 40 base::FilePath full_file_name, dir;
41 GetDestinationPaths("a", &full_file_name, &dir); 41 GetDestinationPaths("a", &full_file_name, &dir);
42 scoped_refptr<SavePackage> save_package(new SavePackage( 42 scoped_refptr<SavePackage> save_package(new SavePackage(
43 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name, 43 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name,
44 dir)); 44 dir));
45 ASSERT_TRUE(test_server()->Stop());
46 } 45 }
47 46
48 // Create a SavePackage, call Cancel, then delete it. 47 // Create a SavePackage, call Cancel, then delete it.
49 // SavePackage dtor has various asserts/checks that should not fire. 48 // SavePackage dtor has various asserts/checks that should not fire.
50 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ExplicitCancel) { 49 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ExplicitCancel) {
51 ASSERT_TRUE(test_server()->Start()); 50 ASSERT_TRUE(embedded_test_server()->Start());
52 GURL url = test_server()->GetURL(kTestFile); 51 GURL url = embedded_test_server()->GetURL(kTestFile);
53 NavigateToURL(shell(), url); 52 NavigateToURL(shell(), url);
54 base::FilePath full_file_name, dir; 53 base::FilePath full_file_name, dir;
55 GetDestinationPaths("a", &full_file_name, &dir); 54 GetDestinationPaths("a", &full_file_name, &dir);
56 scoped_refptr<SavePackage> save_package(new SavePackage( 55 scoped_refptr<SavePackage> save_package(new SavePackage(
57 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name, 56 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name,
58 dir)); 57 dir));
59 save_package->Cancel(true); 58 save_package->Cancel(true);
60 ASSERT_TRUE(test_server()->Stop());
61 } 59 }
62 60
63 } // namespace content 61 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698