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

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

Issue 12213066: Use base namespace for FilePath in content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
11 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
12 #include "content/shell/shell.h" 12 #include "content/shell/shell.h"
13 #include "content/test/content_browser_test.h" 13 #include "content/test/content_browser_test.h"
14 #include "content/test/content_browser_test_utils.h" 14 #include "content/test/content_browser_test_utils.h"
15 #include "net/test/test_server.h" 15 #include "net/test/test_server.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 class MHTMLGenerationTest : public ContentBrowserTest { 20 class MHTMLGenerationTest : public ContentBrowserTest {
21 public: 21 public:
22 MHTMLGenerationTest() : mhtml_generated_(false), file_size_(0) {} 22 MHTMLGenerationTest() : mhtml_generated_(false), file_size_(0) {}
23 23
24 void MHTMLGenerated(const FilePath& path, int64 size) { 24 void MHTMLGenerated(const base::FilePath& path, int64 size) {
25 mhtml_generated_ = true; 25 mhtml_generated_ = true;
26 file_size_ = size; 26 file_size_ = size;
27 MessageLoopForUI::current()->Quit(); 27 MessageLoopForUI::current()->Quit();
28 } 28 }
29 29
30 protected: 30 protected:
31 virtual void SetUp() { 31 virtual void SetUp() {
32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 32 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
33 ContentBrowserTest::SetUp(); 33 ContentBrowserTest::SetUp();
34 } 34 }
35 35
36 bool mhtml_generated() const { return mhtml_generated_; } 36 bool mhtml_generated() const { return mhtml_generated_; }
37 int64 file_size() const { return file_size_; } 37 int64 file_size() const { return file_size_; }
38 38
39 base::ScopedTempDir temp_dir_; 39 base::ScopedTempDir temp_dir_;
40 40
41 private: 41 private:
42 bool mhtml_generated_; 42 bool mhtml_generated_;
43 int64 file_size_; 43 int64 file_size_;
44 }; 44 };
45 45
46 // Tests that generating a MHTML does create contents. 46 // Tests that generating a MHTML does create contents.
47 // Note that the actual content of the file is not tested, the purpose of this 47 // Note that the actual content of the file is not tested, the purpose of this
48 // test is to ensure we were successfull in creating the MHTML data from the 48 // test is to ensure we were successfull in creating the MHTML data from the
49 // renderer. 49 // renderer.
50 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { 50 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
51 ASSERT_TRUE(test_server()->Start()); 51 ASSERT_TRUE(test_server()->Start());
52 52
53 FilePath path(temp_dir_.path()); 53 base::FilePath path(temp_dir_.path());
54 path = path.Append(FILE_PATH_LITERAL("test.mht")); 54 path = path.Append(FILE_PATH_LITERAL("test.mht"));
55 55
56 NavigateToURL(shell(), test_server()->GetURL("files/simple_page.html")); 56 NavigateToURL(shell(), test_server()->GetURL("files/simple_page.html"));
57 57
58 shell()->web_contents()->GenerateMHTML( 58 shell()->web_contents()->GenerateMHTML(
59 path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this)); 59 path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this));
60 60
61 // Block until the MHTML is generated. 61 // Block until the MHTML is generated.
62 RunMessageLoop(); 62 RunMessageLoop();
63 63
64 EXPECT_TRUE(mhtml_generated()); 64 EXPECT_TRUE(mhtml_generated());
65 EXPECT_GT(file_size(), 0); 65 EXPECT_GT(file_size(), 0);
66 66
67 // Make sure the actual generated file has some contents. 67 // Make sure the actual generated file has some contents.
68 int64 file_size; 68 int64 file_size;
69 ASSERT_TRUE(file_util::GetFileSize(path, &file_size)); 69 ASSERT_TRUE(file_util::GetFileSize(path, &file_size));
70 EXPECT_GT(file_size, 100); 70 EXPECT_GT(file_size, 100);
71 } 71 }
72 72
73 } // namespace content 73 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/file_metadata_unittest_linux.cc ('k') | content/browser/download/mhtml_generation_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698