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

Unified 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: Style fixes 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/mhtml_generation_browsertest.cc
diff --git a/chrome/browser/download/mhtml_generation_browsertest.cc b/chrome/browser/download/mhtml_generation_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..468bbb3fcc31c14014113114b06c41befdcb0b34
--- /dev/null
+++ b/chrome/browser/download/mhtml_generation_browsertest.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/file_path.h"
+#include "chrome/browser/download/mhtml_generation_manager.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/test/in_process_browser_test.h"
+#include "chrome/test/testing_browser_process.h"
+#include "chrome/test/ui_test_utils.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "net/test/test_server.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class MHTMLGenerationTest : public InProcessBrowserTest {
+ public:
+ MHTMLGenerationTest() {}
+
+ 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.
+
+ protected:
+ virtual void TearDown() {
+ InProcessBrowserTest::TearDown();
+
+ if (!delete_on_teardown_.empty())
+ file_util::Delete(delete_on_teardown_, false);
+ }
+
+ private:
+ 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.
+
+ 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
+};
+
+IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
+ ASSERT_TRUE(test_server()->Start());
+
+ FilePath path;
+ ASSERT_TRUE(file_util::CreateTemporaryFile(&path));
+ delete_on_teardown_ = path;
+
+ ui_test_utils::NavigateToURL(browser(),
+ test_server()->GetURL("files/google/google.html"));
+
+ TabContents* tab = browser()->GetSelectedTabContentsWrapper()->tab_contents();
+ MHTMLGenerationManager* mhtml_generation_manager =
+ g_browser_process->mhtml_generation_manager();
+
+ Source<RenderViewHost> source(tab->render_view_host());
+ ui_test_utils::WindowedNotificationObserverWithDetails<
+ MHTMLGenerationManager::NotificationDetails> signal(
+ NotificationType::MHTML_GENERATED, source);
+ mhtml_generation_manager->GenerateMHTML(tab, path);
+ signal.Wait();
+
+ MHTMLGenerationManager::NotificationDetails details;
+ ASSERT_TRUE(signal.GetDetailsFor(source.map_key(), &details));
+ ASSERT_TRUE(details.success);
+
+ // 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
+ int64 file_size;
+ ASSERT_TRUE(file_util::GetFileSize(path, &file_size));
+ EXPECT_GT(file_size, 100);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698