OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/file_path.h" | |
6 #include "chrome/browser/download/mhtml_generation_manager.h" | |
7 #include "chrome/browser/ui/browser.h" | |
8 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
9 #include "chrome/test/in_process_browser_test.h" | |
10 #include "chrome/test/testing_browser_process.h" | |
11 #include "chrome/test/ui_test_utils.h" | |
12 #include "content/browser/tab_contents/tab_contents.h" | |
13 #include "net/test/test_server.h" | |
14 #include "testing/gtest/include/gtest/gtest.h" | |
15 | |
16 namespace { | |
17 | |
18 class MHTMLGenerationTest : public InProcessBrowserTest { | |
19 public: | |
20 MHTMLGenerationTest() {} | |
21 | |
22 FilePath delete_on_teardown_; | |
Paweł Hajdan Jr.
2011/06/10 07:15:51
Please use ScopedTempDir.
Jay Civelli
2011/06/10 22:38:22
Done.
| |
23 | |
24 protected: | |
25 virtual void TearDown() { | |
26 InProcessBrowserTest::TearDown(); | |
27 | |
28 if (!delete_on_teardown_.empty()) | |
29 file_util::Delete(delete_on_teardown_, false); | |
30 } | |
31 | |
32 private: | |
33 ScopedTestingBrowserProcess testing_browser_process_; | |
Paweł Hajdan Jr.
2011/06/10 07:15:51
Why do you use a TestingBrowserProcess here? InPro
Jay Civelli
2011/06/10 22:38:22
OK, removed.
| |
34 | |
35 DISALLOW_COPY_AND_ASSIGN(MHTMLGenerationTest); | |
Paweł Hajdan Jr.
2011/06/10 07:15:51
nit: No need for that in the test fixture.
Jay Civelli
2011/06/10 22:38:22
OK
| |
36 }; | |
37 | |
38 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) { | |
39 ASSERT_TRUE(test_server()->Start()); | |
40 | |
41 FilePath path; | |
42 ASSERT_TRUE(file_util::CreateTemporaryFile(&path)); | |
43 delete_on_teardown_ = path; | |
44 | |
45 ui_test_utils::NavigateToURL(browser(), | |
46 test_server()->GetURL("files/google/google.html")); | |
47 | |
48 TabContents* tab = browser()->GetSelectedTabContentsWrapper()->tab_contents(); | |
49 MHTMLGenerationManager* mhtml_generation_manager = | |
50 g_browser_process->mhtml_generation_manager(); | |
51 | |
52 Source<RenderViewHost> source(tab->render_view_host()); | |
53 ui_test_utils::WindowedNotificationObserverWithDetails< | |
54 MHTMLGenerationManager::NotificationDetails> signal( | |
55 NotificationType::MHTML_GENERATED, source); | |
56 mhtml_generation_manager->GenerateMHTML(tab, path); | |
57 signal.Wait(); | |
58 | |
59 MHTMLGenerationManager::NotificationDetails details; | |
60 ASSERT_TRUE(signal.GetDetailsFor(source.map_key(), &details)); | |
61 ASSERT_TRUE(details.success); | |
62 | |
63 // Make sure the generated file has some contents. | |
Paweł Hajdan Jr.
2011/06/10 07:15:51
Why not test that the contents match the expectati
Jay Civelli
2011/06/10 22:38:22
The MHTML content contains date and random boundar
| |
64 int64 file_size; | |
65 ASSERT_TRUE(file_util::GetFileSize(path, &file_size)); | |
66 EXPECT_GT(file_size, 100); | |
67 } | |
68 | |
69 } // namespace | |
OLD | NEW |