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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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 <stdint.h>
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/callback.h" 8 #include "base/callback.h"
7 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/macros.h"
10 #include "base/run_loop.h" 13 #include "base/run_loop.h"
11 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
12 #include "content/public/test/browser_test_utils.h" 15 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h" 16 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h" 17 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
16 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
17 #include "net/dns/mock_host_resolver.h" 20 #include "net/dns/mock_host_resolver.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h" 21 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 23 matching lines...) Expand all
43 path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this, 46 path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this,
44 run_loop.QuitClosure())); 47 run_loop.QuitClosure()));
45 48
46 // Block until the MHTML is generated. 49 // Block until the MHTML is generated.
47 run_loop.Run(); 50 run_loop.Run();
48 51
49 EXPECT_TRUE(has_mhtml_callback_run()); 52 EXPECT_TRUE(has_mhtml_callback_run());
50 } 53 }
51 54
52 bool has_mhtml_callback_run() const { return has_mhtml_callback_run_; } 55 bool has_mhtml_callback_run() const { return has_mhtml_callback_run_; }
53 int64 file_size() const { return file_size_; } 56 int64_t file_size() const { return file_size_; }
54 57
55 base::ScopedTempDir temp_dir_; 58 base::ScopedTempDir temp_dir_;
56 59
57 private: 60 private:
58 void MHTMLGenerated(base::Closure quit_closure, int64 size) { 61 void MHTMLGenerated(base::Closure quit_closure, int64_t size) {
59 has_mhtml_callback_run_ = true; 62 has_mhtml_callback_run_ = true;
60 file_size_ = size; 63 file_size_ = size;
61 quit_closure.Run(); 64 quit_closure.Run();
62 } 65 }
63 66
64 bool has_mhtml_callback_run_; 67 bool has_mhtml_callback_run_;
65 int64 file_size_; 68 int64_t file_size_;
66 }; 69 };
67 70
68 // Tests that generating a MHTML does create contents. 71 // Tests that generating a MHTML does create contents.
69 // Note that the actual content of the file is not tested, the purpose of this 72 // Note that the actual content of the file is not tested, the purpose of this
70 // test is to ensure we were successful in creating the MHTML data from the 73 // test is to ensure we were successful in creating the MHTML data from the
71 // renderer. 74 // renderer.
72 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { 75 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
73 base::FilePath path(temp_dir_.path()); 76 base::FilePath path(temp_dir_.path());
74 path = path.Append(FILE_PATH_LITERAL("test.mht")); 77 path = path.Append(FILE_PATH_LITERAL("test.mht"));
75 78
76 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html")); 79 GenerateMHTML(path, embedded_test_server()->GetURL("/simple_page.html"));
77 ASSERT_FALSE(HasFailure()); 80 ASSERT_FALSE(HasFailure());
78 81
79 // Make sure the actual generated file has some contents. 82 // Make sure the actual generated file has some contents.
80 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback. 83 EXPECT_GT(file_size(), 0); // Verify the size reported by the callback.
81 int64 file_size; 84 int64_t file_size;
82 ASSERT_TRUE(base::GetFileSize(path, &file_size)); 85 ASSERT_TRUE(base::GetFileSize(path, &file_size));
83 EXPECT_GT(file_size, 100); // Verify the actual file size. 86 EXPECT_GT(file_size, 100); // Verify the actual file size.
84 } 87 }
85 88
86 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, InvalidPath) { 89 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, InvalidPath) {
87 base::FilePath path(FILE_PATH_LITERAL("/invalid/file/path")); 90 base::FilePath path(FILE_PATH_LITERAL("/invalid/file/path"));
88 91
89 GenerateMHTML(path, embedded_test_server()->GetURL( 92 GenerateMHTML(path, embedded_test_server()->GetURL(
90 "/download/local-about-blank-subframes.html")); 93 "/download/local-about-blank-subframes.html"));
91 ASSERT_FALSE(HasFailure()); // No failures with the invocation itself? 94 ASSERT_FALSE(HasFailure()); // No failures with the invocation itself?
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 144
142 // Make sure that URLs of both frames are present 145 // Make sure that URLs of both frames are present
143 // (note that these are single-line regexes). 146 // (note that these are single-line regexes).
144 EXPECT_THAT( 147 EXPECT_THAT(
145 mhtml, 148 mhtml,
146 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); 149 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html"));
147 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); 150 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html"));
148 } 151 }
149 152
150 } // namespace content 153 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/file_metadata_unittest_linux.cc ('k') | content/browser/download/mhtml_generation_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698