Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | |
| 9 #include "base/path_service.h" | |
| 8 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 9 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 10 #include "base/test/test_file_util.h" | 12 #include "base/test/test_file_util.h" |
| 11 #include "base/threading/simple_thread.h" | 13 #include "base/threading/simple_thread.h" |
| 12 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/test/automation/tab_proxy.h" | 15 #include "chrome/browser/printing/print_job.h" |
| 14 #include "chrome/test/ui/ui_test.h" | 16 #include "chrome/browser/printing/print_view_manager.h" |
| 17 #include "chrome/browser/ui/browser.h" | |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
| 19 #include "chrome/common/chrome_paths.h" | |
| 20 #include "chrome/common/chrome_switches.h" | |
| 21 #include "chrome/common/chrome_notification_types.h" | |
| 22 #include "chrome/test/base/in_process_browser_test.h" | |
| 23 #include "chrome/test/base/ui_test_utils.h" | |
| 24 #include "content/public/browser/notification_observer.h" | |
| 25 #include "content/public/browser/notification_registrar.h" | |
| 26 #include "content/public/browser/notification_service.h" | |
| 15 #include "net/test/test_server.h" | 27 #include "net/test/test_server.h" |
| 16 #include "printing/image.h" | 28 #include "printing/image.h" |
| 17 #include "printing/printing_test.h" | 29 #include "printing/printing_test.h" |
| 18 | 30 |
| 19 namespace { | 31 namespace { |
| 20 | 32 |
| 21 using printing::Image; | 33 using printing::Image; |
| 22 | 34 |
| 23 const char kGenerateSwitch[] = "print-layout-generate"; | 35 const char kGenerateSwitch[] = "print-layout-generate"; |
| 24 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 36 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
| 25 | 37 |
| 26 class PrintingLayoutTest : public PrintingTest<UITest> { | 38 class PrintingLayoutTest : public PrintingTest<InProcessBrowserTest>, |
| 39 public content::NotificationObserver { | |
| 27 public: | 40 public: |
| 28 PrintingLayoutTest() { | 41 PrintingLayoutTest() { |
| 29 emf_path_ = browser_directory_.AppendASCII("metafile_dumps"); | 42 FilePath browser_directory; |
| 30 launch_arguments_.AppendSwitchPath("debug-print", emf_path_); | 43 PathService::Get(chrome::DIR_APP, &browser_directory); |
| 31 show_window_ = true; | 44 emf_path_ = browser_directory.AppendASCII("metafile_dumps"); |
| 32 } | 45 } |
| 33 | 46 |
| 34 virtual void SetUp() { | 47 virtual void SetUp() OVERRIDE { |
| 35 // Make sure there is no left overs. | 48 // Make sure there is no left overs. |
| 36 CleanupDumpDirectory(); | 49 CleanupDumpDirectory(); |
| 37 UITest::SetUp(); | 50 InProcessBrowserTest::SetUp(); |
| 38 } | 51 } |
| 39 | 52 |
| 40 virtual void TearDown() { | 53 virtual void TearDown() OVERRIDE { |
| 41 UITest::TearDown(); | 54 InProcessBrowserTest::TearDown(); |
| 42 file_util::Delete(emf_path_, true); | 55 file_util::Delete(emf_path_, true); |
| 43 } | 56 } |
| 44 | 57 |
| 58 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 59 command_line->AppendSwitchPath(switches::kDebugPrint, emf_path_); | |
| 60 } | |
| 61 | |
| 45 protected: | 62 protected: |
| 46 void PrintNowTab() { | 63 void PrintNowTab() { |
| 47 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 64 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, |
| 48 ASSERT_TRUE(tab_proxy.get()); | 65 content::NotificationService::AllSources()); |
| 49 ASSERT_TRUE(tab_proxy->PrintNow()); | 66 |
| 67 content::WebContents* web_contents = browser()->GetSelectedWebContents(); | |
|
Lei Zhang
2012/04/09 19:44:44
Just call browser()->GetSelectedTabContentsWrapper
jam
2012/04/09 20:16:22
Done.
| |
| 68 TabContentsWrapper* wrapper = | |
| 69 TabContentsWrapper::GetCurrentWrapperForContents(web_contents); | |
| 70 wrapper->print_view_manager()->PrintNow(); | |
| 71 ui_test_utils::RunMessageLoop(); | |
| 72 registrar_.RemoveAll(); | |
| 73 } | |
| 74 | |
| 75 virtual void Observe(int type, | |
| 76 const content::NotificationSource& source, | |
| 77 const content::NotificationDetails& details) { | |
| 78 DCHECK(type == chrome::NOTIFICATION_PRINT_JOB_EVENT); | |
| 79 switch (content::Details<printing::JobEventDetails>(details)->type()) { | |
| 80 case printing::JobEventDetails::JOB_DONE: { | |
| 81 // Succeeded. | |
| 82 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | |
| 83 break; | |
| 84 } | |
| 85 case printing::JobEventDetails::USER_INIT_CANCELED: | |
| 86 case printing::JobEventDetails::FAILED: { | |
| 87 // Failed. | |
| 88 ASSERT_TRUE(false); | |
| 89 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | |
| 90 break; | |
| 91 } | |
| 92 case printing::JobEventDetails::NEW_DOC: | |
| 93 case printing::JobEventDetails::USER_INIT_DONE: | |
| 94 case printing::JobEventDetails::DEFAULT_INIT_DONE: | |
| 95 case printing::JobEventDetails::NEW_PAGE: | |
| 96 case printing::JobEventDetails::PAGE_DONE: | |
| 97 case printing::JobEventDetails::DOC_DONE: | |
| 98 case printing::JobEventDetails::ALL_PAGES_REQUESTED: { | |
| 99 // Don't care. | |
| 100 break; | |
| 101 } | |
| 102 default: { | |
| 103 NOTREACHED(); | |
| 104 break; | |
| 105 } | |
| 106 } | |
| 50 } | 107 } |
| 51 | 108 |
| 52 // Finds the dump for the last print job and compares it to the data named | 109 // Finds the dump for the last print job and compares it to the data named |
| 53 // |verification_name|. Compares the saved printed job pixels with the test | 110 // |verification_name|. Compares the saved printed job pixels with the test |
| 54 // data pixels and returns the percentage of different pixels; 0 for success, | 111 // data pixels and returns the percentage of different pixels; 0 for success, |
| 55 // [0, 100] for failure. | 112 // [0, 100] for failure. |
| 56 double CompareWithResult(const std::wstring& verification_name) { | 113 double CompareWithResult(const std::wstring& verification_name) { |
| 57 FilePath test_result(ScanFiles(verification_name)); | 114 FilePath test_result(ScanFiles(verification_name)); |
| 58 if (test_result.value().empty()) { | 115 if (test_result.value().empty()) { |
| 59 // 100% different, the print job buffer is not there. | 116 // 100% different, the print job buffer is not there. |
| 60 return 100.; | 117 return 100.; |
| 61 } | 118 } |
| 62 | 119 |
| 63 FilePath base_path(test_data_directory_.AppendASCII("printing")); | 120 FilePath base_path(ui_test_utils::GetTestFilePath( |
| 121 FilePath().AppendASCII("printing"), FilePath())); | |
|
Lei Zhang
2012/04/09 19:44:44
FilePath().AppendASCII("printing") -> FilePath(L"p
jam
2012/04/09 20:16:22
I didn't do it that way because that would make po
| |
| 64 FilePath emf(base_path.Append(verification_name + L".emf")); | 122 FilePath emf(base_path.Append(verification_name + L".emf")); |
| 65 FilePath png(base_path.Append(verification_name + L".png")); | 123 FilePath png(base_path.Append(verification_name + L".png")); |
| 66 | 124 |
| 67 FilePath cleartype(base_path.Append(verification_name + L"_cleartype.png")); | 125 FilePath cleartype(base_path.Append(verification_name + L"_cleartype.png")); |
| 68 // Looks for Cleartype override. | 126 // Looks for Cleartype override. |
| 69 if (file_util::PathExists(cleartype) && IsClearTypeEnabled()) | 127 if (file_util::PathExists(cleartype) && IsClearTypeEnabled()) |
| 70 png = cleartype; | 128 png = cleartype; |
| 71 | 129 |
| 72 if (GenerateFiles()) { | 130 if (GenerateFiles()) { |
| 73 // Copy the .emf and generate an .png. | 131 // Copy the .emf and generate an .png. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 103 FilePath rendering( | 161 FilePath rendering( |
| 104 base_path.Append(verification_name + L"_rendering.png")); | 162 base_path.Append(verification_name + L"_rendering.png")); |
| 105 emf_content.SaveToPng(rendering); | 163 emf_content.SaveToPng(rendering); |
| 106 } | 164 } |
| 107 return std::max(diff_png, diff_emf); | 165 return std::max(diff_png, diff_emf); |
| 108 } | 166 } |
| 109 } | 167 } |
| 110 | 168 |
| 111 // Makes sure the directory exists and is empty. | 169 // Makes sure the directory exists and is empty. |
| 112 void CleanupDumpDirectory() { | 170 void CleanupDumpDirectory() { |
| 113 EXPECT_TRUE(file_util::DieFileDie(emf_path(), true)); | 171 EXPECT_TRUE(file_util::DieFileDie(emf_path_, true)); |
| 114 EXPECT_TRUE(file_util::CreateDirectory(emf_path())); | 172 EXPECT_TRUE(file_util::CreateDirectory(emf_path_)); |
| 115 } | 173 } |
| 116 | 174 |
| 117 // Returns if Clear Type is currently enabled. | 175 // Returns if Clear Type is currently enabled. |
| 118 static bool IsClearTypeEnabled() { | 176 static bool IsClearTypeEnabled() { |
| 119 BOOL ct_enabled = 0; | 177 BOOL ct_enabled = 0; |
| 120 if (SystemParametersInfo(SPI_GETCLEARTYPE, 0, &ct_enabled, 0) && ct_enabled) | 178 if (SystemParametersInfo(SPI_GETCLEARTYPE, 0, &ct_enabled, 0) && ct_enabled) |
| 121 return true; | 179 return true; |
| 122 UINT smoothing = 0; | 180 UINT smoothing = 0; |
| 123 if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &smoothing, 0) && | 181 if (SystemParametersInfo(SPI_GETFONTSMOOTHINGTYPE, 0, &smoothing, 0) && |
| 124 smoothing == FE_FONTSMOOTHINGCLEARTYPE) | 182 smoothing == FE_FONTSMOOTHINGCLEARTYPE) |
| 125 return true; | 183 return true; |
| 126 return false; | 184 return false; |
| 127 } | 185 } |
| 128 | 186 |
| 129 private: | 187 private: |
| 130 // Verifies that there is one .emf and one .prn file in the dump directory. | 188 // Verifies that there is one .emf and one .prn file in the dump directory. |
| 131 // Returns the path of the .emf file and deletes the .prn file. | 189 // Returns the path of the .emf file and deletes the .prn file. |
| 132 std::wstring ScanFiles(const std::wstring& verification_name) { | 190 std::wstring ScanFiles(const std::wstring& verification_name) { |
| 133 // Try to 10 seconds. | 191 // Try to 10 seconds. |
| 134 std::wstring emf_file; | 192 std::wstring emf_file; |
| 135 std::wstring prn_file; | 193 std::wstring prn_file; |
| 136 bool found_emf = false; | 194 bool found_emf = false; |
| 137 bool found_prn = false; | 195 bool found_prn = false; |
| 138 for (int i = 0; i < 100; ++i) { | 196 for (int i = 0; i < 100; ++i) { |
| 139 file_util::FileEnumerator enumerator(emf_path(), false, | 197 file_util::FileEnumerator enumerator(emf_path_, false, |
| 140 file_util::FileEnumerator::FILES); | 198 file_util::FileEnumerator::FILES); |
| 141 emf_file.clear(); | 199 emf_file.clear(); |
| 142 prn_file.clear(); | 200 prn_file.clear(); |
| 143 found_emf = false; | 201 found_emf = false; |
| 144 found_prn = false; | 202 found_prn = false; |
| 145 FilePath file; | 203 FilePath file; |
| 146 while (!(file = enumerator.Next()).empty()) { | 204 while (!(file = enumerator.Next()).empty()) { |
| 147 std::wstring ext = file.Extension(); | 205 std::wstring ext = file.Extension(); |
| 148 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".emf") == 0) { | 206 if (base::strcasecmp(WideToUTF8(ext).c_str(), ".emf") == 0) { |
| 149 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" << | 207 EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" << |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 170 } | 228 } |
| 171 EXPECT_TRUE(found_emf) << ".PRN file is: " << prn_file; | 229 EXPECT_TRUE(found_emf) << ".PRN file is: " << prn_file; |
| 172 EXPECT_TRUE(found_prn) << ".EMF file is: " << emf_file; | 230 EXPECT_TRUE(found_prn) << ".EMF file is: " << emf_file; |
| 173 return emf_file; | 231 return emf_file; |
| 174 } | 232 } |
| 175 | 233 |
| 176 static bool GenerateFiles() { | 234 static bool GenerateFiles() { |
| 177 return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch); | 235 return CommandLine::ForCurrentProcess()->HasSwitch(kGenerateSwitch); |
| 178 } | 236 } |
| 179 | 237 |
| 180 const FilePath& emf_path() const { return emf_path_; } | |
| 181 | |
| 182 FilePath emf_path_; | 238 FilePath emf_path_; |
| 239 content::NotificationRegistrar registrar_; | |
| 183 | 240 |
| 184 DISALLOW_COPY_AND_ASSIGN(PrintingLayoutTest); | 241 DISALLOW_COPY_AND_ASSIGN(PrintingLayoutTest); |
| 185 }; | 242 }; |
| 186 | 243 |
| 187 // Tests that don't need UI access. | |
| 188 class PrintingLayoutTestHidden : public PrintingLayoutTest { | |
| 189 public: | |
| 190 PrintingLayoutTestHidden() { | |
| 191 show_window_ = false; | |
| 192 } | |
| 193 }; | |
| 194 | |
| 195 class PrintingLayoutTextTest : public PrintingLayoutTest { | 244 class PrintingLayoutTextTest : public PrintingLayoutTest { |
| 196 typedef PrintingLayoutTest Parent; | 245 typedef PrintingLayoutTest Parent; |
| 197 public: | 246 public: |
| 198 // Returns if the test is disabled. | 247 // Returns if the test is disabled. |
| 199 // http://crbug.com/64869 Until the issue is fixed, disable the test if | 248 // http://crbug.com/64869 Until the issue is fixed, disable the test if |
| 200 // ClearType is enabled. | 249 // ClearType is enabled. |
| 201 static bool IsTestCaseDisabled() { | 250 static bool IsTestCaseDisabled() { |
| 202 return Parent::IsTestCaseDisabled() || IsClearTypeEnabled(); | 251 return Parent::IsTestCaseDisabled() || IsClearTypeEnabled(); |
| 203 } | 252 } |
| 204 }; | 253 }; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 235 WM_COMMAND, | 284 WM_COMMAND, |
| 236 print_button_id, | 285 print_button_id, |
| 237 reinterpret_cast<LPARAM>(GetDlgItem(dialog_window, print_button_id))); | 286 reinterpret_cast<LPARAM>(GetDlgItem(dialog_window, print_button_id))); |
| 238 return res == 0; | 287 return res == 0; |
| 239 } | 288 } |
| 240 | 289 |
| 241 // Dismiss the first dialog box owned by owner_process by "executing" the | 290 // Dismiss the first dialog box owned by owner_process by "executing" the |
| 242 // default button. | 291 // default button. |
| 243 class DismissTheWindow : public base::DelegateSimpleThread::Delegate { | 292 class DismissTheWindow : public base::DelegateSimpleThread::Delegate { |
| 244 public: | 293 public: |
| 245 explicit DismissTheWindow(DWORD owner_process) | 294 DismissTheWindow() |
| 246 : owner_process_(owner_process) { | 295 : owner_process_(base::Process::Current().pid()) { |
| 247 } | 296 } |
| 248 | 297 |
| 249 virtual void Run() { | 298 virtual void Run() { |
| 250 HWND dialog_window; | 299 HWND dialog_window; |
| 251 for (;;) { | 300 for (;;) { |
| 252 // First enumerate the windows. | 301 // First enumerate the windows. |
| 253 dialog_window = FindDialogWindow(owner_process_); | 302 dialog_window = FindDialogWindow(owner_process_); |
| 254 | 303 |
| 255 // Try to close it. | 304 // Try to close it. |
| 256 if (dialog_window) { | 305 if (dialog_window) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 270 | 319 |
| 271 DWORD owner_process() { return owner_process_; } | 320 DWORD owner_process() { return owner_process_; } |
| 272 | 321 |
| 273 private: | 322 private: |
| 274 DWORD owner_process_; | 323 DWORD owner_process_; |
| 275 }; | 324 }; |
| 276 | 325 |
| 277 } // namespace | 326 } // namespace |
| 278 | 327 |
| 279 // Fails, see http://crbug.com/7721. | 328 // Fails, see http://crbug.com/7721. |
| 280 TEST_F(PrintingLayoutTextTest, DISABLED_Complex) { | 329 IN_PROC_BROWSER_TEST_F(PrintingLayoutTextTest, DISABLED_Complex) { |
| 281 if (IsTestCaseDisabled()) | 330 if (IsTestCaseDisabled()) |
| 282 return; | 331 return; |
| 283 | 332 |
| 284 DismissTheWindow dismisser(base::GetProcId(process())); | 333 DismissTheWindow dismisser; |
| 285 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 334 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
| 286 "close_printdlg_thread"); | 335 "close_printdlg_thread"); |
| 287 | 336 |
| 288 // Print a document, check its output. | 337 // Print a document, check its output. |
| 289 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 338 ASSERT_TRUE(test_server()->Start()); |
| 290 net::TestServer::kLocalhost, | |
| 291 FilePath(kDocRoot)); | |
| 292 ASSERT_TRUE(test_server.Start()); | |
| 293 | 339 |
| 294 NavigateToURL(test_server.GetURL("files/printing/test1.html")); | 340 ui_test_utils::NavigateToURL( |
| 341 browser(), test_server()->GetURL("files/printing/test1.html")); | |
| 295 close_printdlg_thread.Start(); | 342 close_printdlg_thread.Start(); |
| 296 PrintNowTab(); | 343 PrintNowTab(); |
| 297 close_printdlg_thread.Join(); | 344 close_printdlg_thread.Join(); |
| 298 EXPECT_EQ(0., CompareWithResult(L"test1")); | 345 EXPECT_EQ(0., CompareWithResult(L"test1")); |
| 299 } | 346 } |
| 300 | 347 |
| 301 struct TestPool { | 348 struct TestPool { |
| 302 const char* source; | 349 const char* source; |
| 303 const wchar_t* result; | 350 const wchar_t* result; |
| 304 }; | 351 }; |
| 305 | 352 |
| 306 const TestPool kTestPool[] = { | 353 const TestPool kTestPool[] = { |
| 307 // ImagesB&W | 354 // ImagesB&W |
| 308 "files/printing/test2.html", L"test2", | 355 "files/printing/test2.html", L"test2", |
| 309 // ImagesTransparent | 356 // ImagesTransparent |
| 310 "files/printing/test3.html", L"test3", | 357 "files/printing/test3.html", L"test3", |
| 311 // ImageColor | 358 // ImageColor |
| 312 "files/printing/test4.html", L"test4", | 359 "files/printing/test4.html", L"test4", |
| 313 }; | 360 }; |
| 314 | 361 |
| 315 // http://crbug.com/7721 | 362 // http://crbug.com/7721 |
| 316 TEST_F(PrintingLayoutTestHidden, DISABLED_ManyTimes) { | 363 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_ManyTimes) { |
| 317 if (IsTestCaseDisabled()) | 364 if (IsTestCaseDisabled()) |
| 318 return; | 365 return; |
| 319 | 366 |
| 320 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 367 ASSERT_TRUE(test_server()->Start()); |
| 321 net::TestServer::kLocalhost, | |
| 322 FilePath(kDocRoot)); | |
| 323 ASSERT_TRUE(test_server.Start()); | |
| 324 | 368 |
| 325 DismissTheWindow dismisser(base::GetProcId(process())); | 369 DismissTheWindow dismisser; |
| 326 | 370 |
| 327 ASSERT_GT(arraysize(kTestPool), 0u); | 371 ASSERT_GT(arraysize(kTestPool), 0u); |
| 328 for (int i = 0; i < arraysize(kTestPool); ++i) { | 372 for (int i = 0; i < arraysize(kTestPool); ++i) { |
| 329 if (i) | 373 if (i) |
| 330 CleanupDumpDirectory(); | 374 CleanupDumpDirectory(); |
| 331 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; | 375 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; |
| 332 NavigateToURL(test_server.GetURL(test.source)); | 376 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL(test.source)); |
| 333 base::DelegateSimpleThread close_printdlg_thread1(&dismisser, | 377 base::DelegateSimpleThread close_printdlg_thread1(&dismisser, |
| 334 "close_printdlg_thread"); | 378 "close_printdlg_thread"); |
| 335 EXPECT_EQ(NULL, FindDialogWindow(dismisser.owner_process())); | 379 EXPECT_EQ(NULL, FindDialogWindow(dismisser.owner_process())); |
| 336 close_printdlg_thread1.Start(); | 380 close_printdlg_thread1.Start(); |
| 337 PrintNowTab(); | 381 PrintNowTab(); |
| 338 close_printdlg_thread1.Join(); | 382 close_printdlg_thread1.Join(); |
| 339 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 383 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
| 340 CleanupDumpDirectory(); | 384 CleanupDumpDirectory(); |
| 341 base::DelegateSimpleThread close_printdlg_thread2(&dismisser, | 385 base::DelegateSimpleThread close_printdlg_thread2(&dismisser, |
| 342 "close_printdlg_thread"); | 386 "close_printdlg_thread"); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 358 "close_printdlg_thread"); | 402 "close_printdlg_thread"); |
| 359 EXPECT_EQ(NULL, FindDialogWindow(dismisser.owner_process())); | 403 EXPECT_EQ(NULL, FindDialogWindow(dismisser.owner_process())); |
| 360 close_printdlg_thread4.Start(); | 404 close_printdlg_thread4.Start(); |
| 361 PrintNowTab(); | 405 PrintNowTab(); |
| 362 close_printdlg_thread4.Join(); | 406 close_printdlg_thread4.Join(); |
| 363 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 407 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
| 364 } | 408 } |
| 365 } | 409 } |
| 366 | 410 |
| 367 // Prints a popup and immediately closes it. Disabled because it crashes. | 411 // Prints a popup and immediately closes it. Disabled because it crashes. |
| 368 TEST_F(PrintingLayoutTest, DISABLED_Delayed) { | 412 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_Delayed) { |
| 369 if (IsTestCaseDisabled()) | 413 if (IsTestCaseDisabled()) |
| 370 return; | 414 return; |
| 371 | 415 |
| 372 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 416 ASSERT_TRUE(test_server()->Start()); |
| 373 net::TestServer::kLocalhost, | |
| 374 FilePath(kDocRoot)); | |
| 375 ASSERT_TRUE(test_server.Start()); | |
| 376 | 417 |
| 377 { | 418 { |
| 378 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | |
| 379 ASSERT_TRUE(tab_proxy.get()); | |
| 380 bool is_timeout = true; | 419 bool is_timeout = true; |
| 381 GURL url = test_server.GetURL("files/printing/popup_delayed_print.htm"); | 420 GURL url = test_server()->GetURL("files/printing/popup_delayed_print.htm"); |
| 382 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 421 ui_test_utils::NavigateToURL(browser(), url); |
| 383 tab_proxy->NavigateToURL(url)); | |
| 384 | 422 |
| 385 DismissTheWindow dismisser(base::GetProcId(process())); | 423 DismissTheWindow dismisser; |
| 386 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 424 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
| 387 "close_printdlg_thread"); | 425 "close_printdlg_thread"); |
| 388 close_printdlg_thread.Start(); | 426 close_printdlg_thread.Start(); |
| 389 close_printdlg_thread.Join(); | 427 close_printdlg_thread.Join(); |
| 390 | 428 |
| 391 // Force a navigation elsewhere to verify that it's fine with it. | 429 // Force a navigation elsewhere to verify that it's fine with it. |
| 392 url = test_server.GetURL("files/printing/test1.html"); | 430 url = test_server()->GetURL("files/printing/test1.html"); |
| 393 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 431 ui_test_utils::NavigateToURL(browser(), url); |
| 394 tab_proxy->NavigateToURL(url)); | |
| 395 } | 432 } |
| 396 CloseBrowserAndServer(); | 433 browser()->CloseWindow(); |
| 434 ui_test_utils::RunAllPendingInMessageLoop(); | |
| 397 | 435 |
| 398 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) | 436 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) |
| 399 << L"popup_delayed_print"; | 437 << L"popup_delayed_print"; |
| 400 } | 438 } |
| 401 | 439 |
| 402 // Prints a popup and immediately closes it. http://crbug.com/7721 | 440 // Prints a popup and immediately closes it. http://crbug.com/7721 |
| 403 TEST_F(PrintingLayoutTest, DISABLED_IFrame) { | 441 IN_PROC_BROWSER_TEST_F(PrintingLayoutTest, DISABLED_IFrame) { |
| 404 if (IsTestCaseDisabled()) | 442 if (IsTestCaseDisabled()) |
| 405 return; | 443 return; |
| 406 | 444 |
| 407 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 445 ASSERT_TRUE(test_server()->Start()); |
| 408 net::TestServer::kLocalhost, | |
| 409 FilePath(kDocRoot)); | |
| 410 ASSERT_TRUE(test_server.Start()); | |
| 411 | 446 |
| 412 { | 447 { |
| 413 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 448 GURL url = test_server()->GetURL("files/printing/iframe.htm"); |
| 414 ASSERT_TRUE(tab_proxy.get()); | 449 ui_test_utils::NavigateToURL(browser(), url); |
| 415 GURL url = test_server.GetURL("files/printing/iframe.htm"); | |
| 416 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | |
| 417 tab_proxy->NavigateToURL(url)); | |
| 418 | 450 |
| 419 DismissTheWindow dismisser(base::GetProcId(process())); | 451 DismissTheWindow dismisser; |
| 420 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 452 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
| 421 "close_printdlg_thread"); | 453 "close_printdlg_thread"); |
| 422 close_printdlg_thread.Start(); | 454 close_printdlg_thread.Start(); |
| 423 close_printdlg_thread.Join(); | 455 close_printdlg_thread.Join(); |
| 424 | 456 |
| 425 // Force a navigation elsewhere to verify that it's fine with it. | 457 // Force a navigation elsewhere to verify that it's fine with it. |
| 426 url = test_server.GetURL("files/printing/test1.html"); | 458 url = test_server()->GetURL("files/printing/test1.html"); |
| 427 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 459 ui_test_utils::NavigateToURL(browser(), url); |
| 428 tab_proxy->NavigateToURL(url)); | |
| 429 } | 460 } |
| 430 CloseBrowserAndServer(); | 461 browser()->CloseWindow(); |
| 462 ui_test_utils::RunAllPendingInMessageLoop(); | |
| 431 | 463 |
| 432 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; | 464 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; |
| 433 } | 465 } |
| OLD | NEW |