summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 21:10:58 +0000
committerscottbyer@chromium.org <scottbyer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 21:10:58 +0000
commit7074e6880ba3af4dcf35ec191704fe4342fc6d27 (patch)
tree6b667f9d5f29c00668cdaf745ed1918c289aba85
parentbe4f7a67fdda2f41e6c73e89f20f9bcdd4979056 (diff)
downloadchromium_src-7074e6880ba3af4dcf35ec191704fe4342fc6d27.zip
chromium_src-7074e6880ba3af4dcf35ec191704fe4342fc6d27.tar.gz
chromium_src-7074e6880ba3af4dcf35ec191704fe4342fc6d27.tar.bz2
Fix crashy test.
http://code.google.com/p/chromium/issues/detail?id=44547 BUG=44547 TEST=PrintDialogCloudTest.HandlersRegistered git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49592 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc2
-rw-r--r--chrome/browser/printing/print_dialog_cloud.h2
-rw-r--r--chrome/browser/printing/print_dialog_cloud_uitest.cc65
3 files changed, 48 insertions, 21 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index 5da3a2ff..796a81d 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -104,7 +104,7 @@ void CloudPrintService::RegisterPreferences() {
if (pref_service->FindPreference(prefs::kCloudPrintServiceURL))
return;
std::wstring kDefaultCloudPrintServiceURL(
- L"http://www.google.com/cloudprint");
+ L"https://www.google.com/cloudprint");
pref_service->RegisterStringPref(prefs::kCloudPrintServiceURL,
kDefaultCloudPrintServiceURL);
}
diff --git a/chrome/browser/printing/print_dialog_cloud.h b/chrome/browser/printing/print_dialog_cloud.h
index 175103a..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_TEST_ALL_PREFIXES(PrintDialogCloudTest, HandlersRegistered);
+ 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 469c060..ec8da96 100644
--- a/chrome/browser/printing/print_dialog_cloud_uitest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_uitest.cc
@@ -50,6 +50,26 @@ class SimpleTestJob : public URLRequestTestJob {
explicit SimpleTestJob(URLRequest* request)
: URLRequestTestJob(request, test_headers(),
Singleton<TestData>()->GetTestData(), true) {}
+
+ virtual void GetResponseInfo(net::HttpResponseInfo* info) {
+ URLRequestTestJob::GetResponseInfo(info);
+ if (request_->url().SchemeIsSecure()) {
+ // Make up a fake certificate for this response since we don't have
+ // access to the real SSL info.
+ const char* kCertIssuer = "Chrome Internal";
+ const int kLifetimeDays = 100;
+
+ info->ssl_info.cert =
+ new net::X509Certificate(request_->url().GetWithEmptyPath().spec(),
+ kCertIssuer,
+ base::Time::Now(),
+ base::Time::Now() +
+ base::TimeDelta::FromDays(kLifetimeDays));
+ info->ssl_info.cert_status = 0;
+ info->ssl_info.security_bits = 0;
+ }
+ }
+
private:
~SimpleTestJob() {}
};
@@ -69,15 +89,21 @@ class TestResult {
const GURL GetExpectedUrl() {
return expected_url_;
}
+ void set_delegate(TestDelegate* delegate) {
+ delegate_ = delegate;
+ }
+ TestDelegate* delegate() {
+ return delegate_;
+ }
private:
bool result_;
GURL expected_url_;
+ TestDelegate* delegate_;
};
} // namespace
-class PrintDialogCloudTest : public InProcessBrowserTest,
- public NotificationObserver {
+class PrintDialogCloudTest : public InProcessBrowserTest {
public:
PrintDialogCloudTest() : handler_added_(false) {
PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_);
@@ -86,6 +112,16 @@ class PrintDialogCloudTest : public InProcessBrowserTest,
// Must be static for handing into AddHostnameHandler.
static URLRequest::ProtocolFactory Factory;
+ class PrintDialogCloudTestDelegate : public TestDelegate {
+ public:
+ PrintDialogCloudTestDelegate() {}
+
+ virtual void OnResponseCompleted(URLRequest* request) {
+ ChromeThread::PostTask(ChromeThread::UI, FROM_HERE,
+ new MessageLoop::QuitTask());
+ }
+ };
+
virtual void SetUp() {
Singleton<TestResult>()->SetResult(false);
InProcessBrowserTest::SetUp();
@@ -96,6 +132,7 @@ class PrintDialogCloudTest : public InProcessBrowserTest,
URLRequestFilter* filter = URLRequestFilter::GetInstance();
filter->RemoveHostnameHandler(scheme_, host_name_);
handler_added_ = false;
+ Singleton<TestResult>()->set_delegate(NULL);
}
InProcessBrowserTest::TearDown();
}
@@ -116,23 +153,11 @@ class PrintDialogCloudTest : public InProcessBrowserTest,
&PrintDialogCloudTest::Factory);
handler_added_ = true;
- registrar_.Add(this, NotificationType::LOAD_STOP,
- NotificationService::AllSources());
-
GURL cloud_print_dialog_url =
internal_cloud_print_helpers::CloudPrintService(browser()->profile()).
GetCloudPrintServiceDialogURL();
Singleton<TestResult>()->SetExpectedUrl(cloud_print_dialog_url);
- }
- }
-
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == NotificationType::LOAD_STOP) {
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
- registrar_.Remove(this, NotificationType::LOAD_STOP,
- NotificationService::AllSources());
+ Singleton<TestResult>()->set_delegate(&delegate_);
}
}
@@ -140,18 +165,18 @@ class PrintDialogCloudTest : public InProcessBrowserTest,
std::string scheme_;
std::string host_name_;
FilePath test_data_directory_;
- NotificationRegistrar registrar_;
+ PrintDialogCloudTestDelegate delegate_;
};
URLRequestJob* PrintDialogCloudTest::Factory(URLRequest* request,
const std::string& scheme) {
+ request->set_delegate(Singleton<TestResult>()->delegate());
if (request && (request->url() == Singleton<TestResult>()->GetExpectedUrl()))
Singleton<TestResult>()->SetResult(true);
return new SimpleTestJob(request);
}
-// Crashy, http://crbug.com/44547.
-IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, DISABLED_HandlersRegistered) {
+IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, HandlersRegistered) {
BrowserList::SetLastActive(browser());
ASSERT_TRUE(BrowserList::GetLastActive());
@@ -159,9 +184,11 @@ IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, DISABLED_HandlersRegistered) {
FilePath pdf_file =
test_data_directory_.AppendASCII("printing/cloud_print_uitest.pdf");
- new PrintDialogCloud(pdf_file);
+ {
+ PrintDialogCloud dialog (pdf_file);
ui_test_utils::RunMessageLoop();
+ }
ASSERT_TRUE(Singleton<TestResult>()->GetResult());
}