| OLD | NEW |
| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/scoped_temp_dir.h" | 7 #include "base/scoped_temp_dir.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chrome/test/base/testing_browser_process.h" | 10 #include "chrome/test/base/testing_browser_process.h" |
| 11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
| 12 #include "content/browser/download/mhtml_generation_manager.h" | |
| 13 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 14 #include "net/test/test_server.h" | 13 #include "net/test/test_server.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 using content::WebContents; | 16 using content::WebContents; |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 class MHTMLGenerationTest : public InProcessBrowserTest { | 20 class MHTMLGenerationTest : public InProcessBrowserTest { |
| 22 public: | 21 public: |
| (...skipping 28 matching lines...) Expand all Loading... |
| 51 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { | 50 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { |
| 52 ASSERT_TRUE(test_server()->Start()); | 51 ASSERT_TRUE(test_server()->Start()); |
| 53 | 52 |
| 54 FilePath path(temp_dir_.path()); | 53 FilePath path(temp_dir_.path()); |
| 55 path = path.Append(FILE_PATH_LITERAL("test.mht")); | 54 path = path.Append(FILE_PATH_LITERAL("test.mht")); |
| 56 | 55 |
| 57 ui_test_utils::NavigateToURL(browser(), | 56 ui_test_utils::NavigateToURL(browser(), |
| 58 test_server()->GetURL("files/google/google.html")); | 57 test_server()->GetURL("files/google/google.html")); |
| 59 | 58 |
| 60 WebContents* tab = browser()->GetSelectedWebContents(); | 59 WebContents* tab = browser()->GetSelectedWebContents(); |
| 61 MHTMLGenerationManager* mhtml_generation_manager = | 60 tab->GenerateMHTML(path, |
| 62 g_browser_process->mhtml_generation_manager(); | 61 base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this)); |
| 63 | |
| 64 mhtml_generation_manager->GenerateMHTML(tab, path, | |
| 65 base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this)); | |
| 66 | 62 |
| 67 // Block until the MHTML is generated. | 63 // Block until the MHTML is generated. |
| 68 ui_test_utils::RunMessageLoop(); | 64 ui_test_utils::RunMessageLoop(); |
| 69 | 65 |
| 70 EXPECT_TRUE(mhtml_generated()); | 66 EXPECT_TRUE(mhtml_generated()); |
| 71 EXPECT_GT(file_size(), 0); | 67 EXPECT_GT(file_size(), 0); |
| 72 | 68 |
| 73 // Make sure the actual generated file has some contents. | 69 // Make sure the actual generated file has some contents. |
| 74 int64 file_size; | 70 int64 file_size; |
| 75 ASSERT_TRUE(file_util::GetFileSize(path, &file_size)); | 71 ASSERT_TRUE(file_util::GetFileSize(path, &file_size)); |
| 76 EXPECT_GT(file_size, 100); | 72 EXPECT_GT(file_size, 100); |
| 77 } | 73 } |
| 78 | 74 |
| 79 } // namespace | 75 } // namespace |
| OLD | NEW |