diff options
author | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-11 21:17:16 +0000 |
---|---|---|
committer | scottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-11 21:17:16 +0000 |
commit | 64f12b64aee02fda94d0a45c6847749f35d0a3ad (patch) | |
tree | 40d20482ae0ff0ae08f600f82aa4e8d96dc121db /chrome/browser/printing | |
parent | e510620c6b1bd4eff20b101c0cdb63166e0b117e (diff) | |
download | chromium_src-64f12b64aee02fda94d0a45c6847749f35d0a3ad.zip chromium_src-64f12b64aee02fda94d0a45c6847749f35d0a3ad.tar.gz chromium_src-64f12b64aee02fda94d0a45c6847749f35d0a3ad.tar.bz2 |
Revert 49593 - Tweaks to the test.
TBR=scottbyer@chromium.org
Review URL: http://codereview.chromium.org/2753011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/printing')
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud.h | 2 | ||||
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud_uitest.cc | 62 |
2 files changed, 22 insertions, 42 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.h b/chrome/browser/printing/print_dialog_cloud.h index 6dacc66..a9736bd 100644 --- a/chrome/browser/printing/print_dialog_cloud.h +++ b/chrome/browser/printing/print_dialog_cloud.h @@ -20,7 +20,7 @@ class PrintDialogCloud { static void CreatePrintDialogForPdf(const FilePath& path_to_pdf); private: - friend class PrintDialogCloudTest; + FRIEND_TEST(PrintDialogCloudTest, HandlersRegistered); explicit PrintDialogCloud(const FilePath& path_to_pdf); ~PrintDialogCloud(); diff --git a/chrome/browser/printing/print_dialog_cloud_uitest.cc b/chrome/browser/printing/print_dialog_cloud_uitest.cc index 6b6f3eb..ec8da96 100644 --- a/chrome/browser/printing/print_dialog_cloud_uitest.cc +++ b/chrome/browser/printing/print_dialog_cloud_uitest.cc @@ -25,9 +25,6 @@ namespace { -// Default delay for the time-out at which we stop message loop. -const int kTimeoutInMS = 200000; - class TestData { public: TestData() {} @@ -77,19 +74,19 @@ class SimpleTestJob : public URLRequestTestJob { ~SimpleTestJob() {} }; -class TestController { +class TestResult { public: - TestController() : result_(false), use_autoquit_delegate_(false) {} - void set_result(bool value) { + TestResult() : result_(false) {} + void SetResult(bool value) { result_ = value; } - bool result() { + bool GetResult() { return result_; } - void set_expected_url(const GURL& url) { + void SetExpectedUrl(const GURL& url) { expected_url_ = url; } - const GURL expected_url() { + const GURL GetExpectedUrl() { return expected_url_; } void set_delegate(TestDelegate* delegate) { @@ -98,15 +95,8 @@ class TestController { TestDelegate* delegate() { return delegate_; } - void set_use_autoquit_delegate(bool value) { - use_autoquit_delegate_ = value; - } - bool use_autoquit_delegate() { - return use_autoquit_delegate_; - } private: bool result_; - bool use_autoquit_delegate_; GURL expected_url_; TestDelegate* delegate_; }; @@ -133,7 +123,7 @@ class PrintDialogCloudTest : public InProcessBrowserTest { }; virtual void SetUp() { - Singleton<TestController>()->set_result(false); + Singleton<TestResult>()->SetResult(false); InProcessBrowserTest::SetUp(); } @@ -142,7 +132,7 @@ class PrintDialogCloudTest : public InProcessBrowserTest { URLRequestFilter* filter = URLRequestFilter::GetInstance(); filter->RemoveHostnameHandler(scheme_, host_name_); handler_added_ = false; - Singleton<TestController>()->set_delegate(NULL); + Singleton<TestResult>()->set_delegate(NULL); } InProcessBrowserTest::TearDown(); } @@ -166,19 +156,9 @@ class PrintDialogCloudTest : public InProcessBrowserTest { GURL cloud_print_dialog_url = internal_cloud_print_helpers::CloudPrintService(browser()->profile()). GetCloudPrintServiceDialogURL(); - Singleton<TestController>()->set_expected_url(cloud_print_dialog_url); - Singleton<TestController>()->set_delegate(&delegate_); + Singleton<TestResult>()->SetExpectedUrl(cloud_print_dialog_url); + Singleton<TestResult>()->set_delegate(&delegate_); } - - CreateDialogForTest(); - } - - void CreateDialogForTest() { - FilePath path_to_pdf = - test_data_directory_.AppendASCII("printing/cloud_print_uitest.pdf"); - ChromeThread::PostTask( - ChromeThread::UI, FROM_HERE, - NewRunnableFunction(&PrintDialogCloud::CreateDialogImpl, path_to_pdf)); } bool handler_added_; @@ -190,12 +170,9 @@ class PrintDialogCloudTest : public InProcessBrowserTest { URLRequestJob* PrintDialogCloudTest::Factory(URLRequest* request, const std::string& scheme) { - if (Singleton<TestController>()->use_autoquit_delegate()) - request->set_delegate(Singleton<TestController>()->delegate()); - if (request && - (request->url() == Singleton<TestController>()->expected_url())) { - Singleton<TestController>()->set_result(true); - } + request->set_delegate(Singleton<TestResult>()->delegate()); + if (request && (request->url() == Singleton<TestResult>()->GetExpectedUrl())) + Singleton<TestResult>()->SetResult(true); return new SimpleTestJob(request); } @@ -205,12 +182,15 @@ IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, HandlersRegistered) { AddTestHandlers(); - Singleton<TestController>()->set_use_autoquit_delegate(true); + FilePath pdf_file = + test_data_directory_.AppendASCII("printing/cloud_print_uitest.pdf"); - ui_test_utils::TimedMessageLoopRunner timed_loop(MessageLoop::current()); - timed_loop.RunFor(kTimeoutInMS); + { + PrintDialogCloud dialog (pdf_file); + ui_test_utils::RunMessageLoop(); + } - ASSERT_TRUE(Singleton<TestController>()->result()); + ASSERT_TRUE(Singleton<TestResult>()->GetResult()); } #if defined(OS_CHROMEOS) @@ -233,6 +213,6 @@ IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, DISABLED_DialogGrabbed) { ui_test_utils::RunMessageLoop(); - ASSERT_TRUE(Singleton<TestController>()->result()); + ASSERT_TRUE(Singleton<TestResult>()->GetResult()); } #endif |