| 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
|
|
|