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

Unified Diff: content/browser/download/mhtml_generation_browsertest.cc

Issue 8674002: Switch MHTMLGenerationManager to use a Callback. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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: content/browser/download/mhtml_generation_browsertest.cc
diff --git a/content/browser/download/mhtml_generation_browsertest.cc b/content/browser/download/mhtml_generation_browsertest.cc
index 8e19f190213de2ec32902f71e7557f4ca770eecb..4b81e35d42d9a88594892d492465549fcaa8106b 100644
--- a/content/browser/download/mhtml_generation_browsertest.cc
+++ b/content/browser/download/mhtml_generation_browsertest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
#include "base/file_path.h"
#include "base/scoped_temp_dir.h"
#include "chrome/browser/ui/browser.h"
@@ -10,7 +11,6 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/download/mhtml_generation_manager.h"
#include "content/browser/tab_contents/tab_contents.h"
-#include "content/public/browser/notification_types.h"
#include "net/test/test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -18,7 +18,13 @@ namespace {
class MHTMLGenerationTest : public InProcessBrowserTest {
public:
- MHTMLGenerationTest() {}
+ MHTMLGenerationTest() : mhtml_generated_(false), file_size_(0) {}
+
+ void MHTMLGenerated(const FilePath& path, int64 size) {
+ mhtml_generated_ = true;
+ file_size_ = size;
+ MessageLoopForUI::current()->Quit();
+ }
protected:
virtual void SetUp() {
@@ -26,7 +32,14 @@ class MHTMLGenerationTest : public InProcessBrowserTest {
InProcessBrowserTest::SetUp();
}
+ bool mhtml_generated() const { return mhtml_generated_; }
+ int64 file_size() const { return file_size_; }
+
ScopedTempDir temp_dir_;
+
+ private:
+ bool mhtml_generated_;
+ int64 file_size_;
};
// Tests that generating a MHTML does create contents.
@@ -46,16 +59,14 @@ IN_PROC_BROWSER_TEST_F(MHTMLGenerationTest, GenerateMHTML) {
MHTMLGenerationManager* mhtml_generation_manager =
g_browser_process->mhtml_generation_manager();
- content::Source<RenderViewHost> source(tab->render_view_host());
- ui_test_utils::WindowedNotificationObserverWithDetails<
- MHTMLGenerationManager::NotificationDetails> signal(
- content::NOTIFICATION_MHTML_GENERATED, source);
- mhtml_generation_manager->GenerateMHTML(tab, path);
- signal.Wait();
+ mhtml_generation_manager->GenerateMHTML(tab, path,
+ base::Bind(&MHTMLGenerationTest::MHTMLGenerated, this));
+
+ // Block until the MHTML is generated.
+ ui_test_utils::RunMessageLoop();
- MHTMLGenerationManager::NotificationDetails details;
- ASSERT_TRUE(signal.GetDetailsFor(source.map_key(), &details));
- ASSERT_GT(details.file_size, 0);
+ EXPECT_TRUE(mhtml_generated());
+ EXPECT_GT(file_size(), 0);
// Make sure the actual generated file has some contents.
int64 file_size;
« no previous file with comments | « chrome/browser/extensions/extension_save_page_api.cc ('k') | content/browser/download/mhtml_generation_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698