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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 private: | 48 private: |
49 bool has_mhtml_callback_run_; | 49 bool has_mhtml_callback_run_; |
50 int64 file_size_; | 50 int64 file_size_; |
51 }; | 51 }; |
52 | 52 |
53 // Tests that generating a MHTML does create contents. | 53 // Tests that generating a MHTML does create contents. |
54 // Note that the actual content of the file is not tested, the purpose of this | 54 // Note that the actual content of the file is not tested, the purpose of this |
55 // test is to ensure we were successfull in creating the MHTML data from the | 55 // test is to ensure we were successfull in creating the MHTML data from the |
56 // renderer. | 56 // renderer. |
57 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { | 57 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { |
58 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 58 ASSERT_TRUE(embedded_test_server()->Start()); |
59 | 59 |
60 base::FilePath path(temp_dir_.path()); | 60 base::FilePath path(temp_dir_.path()); |
61 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 61 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
62 | 62 |
63 NavigateToURL(shell(), embedded_test_server()->GetURL("/simple_page.html")); | 63 NavigateToURL(shell(), embedded_test_server()->GetURL("/simple_page.html")); |
64 | 64 |
65 base::RunLoop run_loop; | 65 base::RunLoop run_loop; |
66 shell()->web_contents()->GenerateMHTML( | 66 shell()->web_contents()->GenerateMHTML( |
67 path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this, | 67 path, base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this, |
68 run_loop.QuitClosure())); | 68 run_loop.QuitClosure())); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 // Make sure that URLs of both frames are present | 157 // Make sure that URLs of both frames are present |
158 // (note that these are single-line regexes). | 158 // (note that these are single-line regexes). |
159 EXPECT_THAT( | 159 EXPECT_THAT( |
160 mhtml, | 160 mhtml, |
161 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); | 161 ContainsRegex("Content-Location:.*/frame_tree/page_with_one_frame.html")); |
162 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); | 162 EXPECT_THAT(mhtml, ContainsRegex("Content-Location:.*/title1.html")); |
163 } | 163 } |
164 | 164 |
165 } // namespace content | 165 } // namespace content |
OLD | NEW |