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

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

Issue 10821089: Add the save_package_browsertest.cc to 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/browser/mouseleave_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/scoped_temp_dir.h" 5 #include "base/scoped_temp_dir.h"
6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/browser_tabstrip.h"
8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "chrome/test/base/ui_test_utils.h"
10 #include "content/browser/download/save_package.h" 6 #include "content/browser/download/save_package.h"
7 #include "content/shell/shell.h"
8 #include "content/test/content_browser_test.h"
9 #include "content/test/content_browser_test_utils.h"
11 10
12 namespace { 11 namespace content {
13 12
14 const char kTestFile[] = "files/save_page/a.htm"; 13 const char kTestFile[] = "files/simple_page.html";
15 14
16 class SavePackageBrowserTest : public InProcessBrowserTest { 15 class SavePackageBrowserTest : public ContentBrowserTest {
17 protected: 16 protected:
18 void SetUp() OVERRIDE { 17 void SetUp() OVERRIDE {
19 ASSERT_TRUE(save_dir_.CreateUniqueTempDir()); 18 ASSERT_TRUE(save_dir_.CreateUniqueTempDir());
20 InProcessBrowserTest::SetUp(); 19 ContentBrowserTest::SetUp();
21 } 20 }
22 21
23 // Returns full paths of destination file and directory. 22 // Returns full paths of destination file and directory.
24 void GetDestinationPaths(const std::string& prefix, 23 void GetDestinationPaths(const std::string& prefix,
25 FilePath* full_file_name, 24 FilePath* full_file_name,
26 FilePath* dir) { 25 FilePath* dir) {
27 *full_file_name = save_dir_.path().AppendASCII(prefix + ".htm"); 26 *full_file_name = save_dir_.path().AppendASCII(prefix + ".htm");
28 *dir = save_dir_.path().AppendASCII(prefix + "_files"); 27 *dir = save_dir_.path().AppendASCII(prefix + "_files");
29 } 28 }
30 29
31 // Temporary directory we will save pages to. 30 // Temporary directory we will save pages to.
32 ScopedTempDir save_dir_; 31 ScopedTempDir save_dir_;
33 }; 32 };
34 33
35 // Create a SavePackage and delete it without calling Init. 34 // Create a SavePackage and delete it without calling Init.
36 // SavePackage dtor has various asserts/checks that should not fire. 35 // SavePackage dtor has various asserts/checks that should not fire.
37 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ImplicitCancel) { 36 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ImplicitCancel) {
38 ASSERT_TRUE(test_server()->Start()); 37 ASSERT_TRUE(test_server()->Start());
39 GURL url = test_server()->GetURL(kTestFile); 38 GURL url = test_server()->GetURL(kTestFile);
40 ui_test_utils::NavigateToURL(browser(), url); 39 NavigateToURL(shell(), url);
41 FilePath full_file_name, dir; 40 FilePath full_file_name, dir;
42 GetDestinationPaths("a", &full_file_name, &dir); 41 GetDestinationPaths("a", &full_file_name, &dir);
43 scoped_refptr<SavePackage> save_package(new SavePackage( 42 scoped_refptr<SavePackage> save_package(new SavePackage(
44 chrome::GetActiveWebContents(browser()), 43 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name,
45 content::SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name, dir)); 44 dir));
46 ASSERT_TRUE(test_server()->Stop()); 45 ASSERT_TRUE(test_server()->Stop());
47 } 46 }
48 47
49 // Create a SavePackage, call Cancel, then delete it. 48 // Create a SavePackage, call Cancel, then delete it.
50 // SavePackage dtor has various asserts/checks that should not fire. 49 // SavePackage dtor has various asserts/checks that should not fire.
51 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ExplicitCancel) { 50 IN_PROC_BROWSER_TEST_F(SavePackageBrowserTest, ExplicitCancel) {
52 ASSERT_TRUE(test_server()->Start()); 51 ASSERT_TRUE(test_server()->Start());
53 GURL url = test_server()->GetURL(kTestFile); 52 GURL url = test_server()->GetURL(kTestFile);
54 ui_test_utils::NavigateToURL(browser(), url); 53 NavigateToURL(shell(), url);
55 FilePath full_file_name, dir; 54 FilePath full_file_name, dir;
56 GetDestinationPaths("a", &full_file_name, &dir); 55 GetDestinationPaths("a", &full_file_name, &dir);
57 scoped_refptr<SavePackage> save_package(new SavePackage( 56 scoped_refptr<SavePackage> save_package(new SavePackage(
58 chrome::GetActiveWebContents(browser()), 57 shell()->web_contents(), SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name,
59 content::SAVE_PAGE_TYPE_AS_ONLY_HTML, full_file_name, dir)); 58 dir));
60 save_package->Cancel(true); 59 save_package->Cancel(true);
61 ASSERT_TRUE(test_server()->Stop()); 60 ASSERT_TRUE(test_server()->Stop());
62 } 61 }
63 62
64 } // namespace 63 } // namespace content
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/browser/mouseleave_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698