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

Unified Diff: chrome/browser/printing/print_preview_pdf_generated_browsertest.cc

Issue 410473002: Assertion removed in print_preview_pdf_generated.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Message loop ends when file is saved. Created 6 years, 5 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/printing/print_preview_pdf_generated_browsertest.cc
diff --git a/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc b/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
index 8977fc240107fb38536856cfa489998ec16d083d..1335e4051dc08ca2459afc46c0bb58f304f6c016 100644
--- a/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
+++ b/chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
@@ -11,6 +11,8 @@
#include <utility>
#include <vector>
+#include "base/bind.h"
+#include "base/callback.h"
#include "base/file_util.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
@@ -272,10 +274,6 @@ class PrintPreviewObserver : public WebContentsObserver {
Observe(new_web_contents);
}
- virtual void WebContentsDestroyed() OVERRIDE {
- EndLoop();
- }
-
Browser* browser_;
base::Closure quit_closure_;
scoped_ptr<PrintPreviewSettings> settings_;
@@ -316,23 +314,17 @@ class PrintPreviewPdfGeneratedBrowserTest : public InProcessBrowserTest {
base::RunLoop loop;
print_preview_observer_->set_quit_closure(loop.QuitClosure());
+
+ // Callback that is called by PrintPreviewHandler and ends
+ // |print_preview_observer|'s message loop when the file has been saved.
+ base::Closure callback =
+ base::Bind(&PrintPreviewObserver::EndLoop,
+ base::Unretained(print_preview_observer_.get()));
+ print_preview_observer_->GetUI()->SetCallbackForTesting(&callback);
+
print_preview_observer_->GetUI()->SetSelectedFileForTesting(
pdf_file_save_path_);
loop.Run();
-
- // Checks to see if the file exists and is readable. If the file doesn't
- // exist, the test will fail. If it exists, but isn't readable, the test
- // will keep polling until the file becomes readable. This is due to a
- // problem on Windows where the file exists, but isn't readable, causing
- // other ASSERT statements in this test to fail.
- // TODO(ivandavid): Come up with a better way to do this.
- ASSERT_TRUE(base::PathExists(pdf_file_save_path_));
- while (true) {
- base::File pdf_file(
- pdf_file_save_path_, base::File::FLAG_OPEN | base::File::FLAG_READ);
- if (pdf_file.IsValid())
- break;
- }
}
// Initializes function pointers from the PDF library. Called once when the

Powered by Google App Engine
This is Rietveld 408576698