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

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

Issue 7044095: Hooking MHTML generation to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor clean-up Created 9 years, 6 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
(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 "base/scoped_temp_dir.h"
7 #include "chrome/browser/download/mhtml_generation_manager.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "chrome/test/in_process_browser_test.h"
11 #include "chrome/test/testing_browser_process.h"
12 #include "chrome/test/ui_test_utils.h"
13 #include "content/browser/tab_contents/tab_contents.h"
14 #include "net/test/test_server.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 namespace {
18
19 class MHTMLGenerationTest : public InProcessBrowserTest {
20 public:
21 MHTMLGenerationTest() {}
22
23 FilePath delete_on_teardown_;
Paweł Hajdan Jr. 2011/06/11 18:04:45 This is now unused, please remove it.
Jay Civelli 2011/06/13 22:45:41 Done.
24
25 protected:
26 virtual void SetUp() {
27 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
28 InProcessBrowserTest::SetUp();
29 }
30
31 virtual void TearDown() {
32 InProcessBrowserTest::TearDown();
33
34 if (!delete_on_teardown_.empty())
35 file_util::Delete(delete_on_teardown_, false);
36 }
37
38 ScopedTempDir temp_dir_;
39 };
40
41 // Tests that generating a MHTML does create contents.
42 // Note that the actual content of the file is not tested, the purpose of this
43 // test is to ensure we were successfull in creating the MHTML data from the
44 // renderer.
45 IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
46 ASSERT_TRUE(test_server()->Start());
47
48 FilePath path(temp_dir_.path());
49 path = path.Append(FILE_PATH_LITERAL("test.mht"));
50
51 ui_test_utils::NavigateToURL(browser(),
52 test_server()->GetURL("files/google/google.html"));
53
54 TabContents* tab = browser()->GetSelectedTabContentsWrapper()->tab_contents();
55 MHTMLGenerationManager* mhtml_generation_manager =
56 g_browser_process->mhtml_generation_manager();
57
58 Source<RenderViewHost> source(tab->render_view_host());
59 ui_test_utils::WindowedNotificationObserverWithDetails<
60 MHTMLGenerationManager::NotificationDetails> signal(
61 NotificationType::MHTML_GENERATED, source);
62 mhtml_generation_manager->GenerateMHTML(tab, path);
63 signal.Wait();
64
65 MHTMLGenerationManager::NotificationDetails details;
66 ASSERT_TRUE(signal.GetDetailsFor(source.map_key(), &details));
67 ASSERT_TRUE(details.success);
68
69 // Make sure the generated file has some contents.
70 int64 file_size;
71 ASSERT_TRUE(file_util::GetFileSize(path, &file_size));
72 EXPECT_GT(file_size, 100);
73 }
74
75 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698