| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/simple_thread.h" | 7 #include "base/simple_thread.h" |
| 8 #include "base/test/test_file_util.h" | 8 #include "base/test/test_file_util.h" |
| 9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
| 10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
| 11 #include "chrome/test/automation/browser_proxy.h" | 11 #include "chrome/test/automation/browser_proxy.h" |
| 12 #include "chrome/test/automation/tab_proxy.h" | 12 #include "chrome/test/automation/tab_proxy.h" |
| 13 #include "chrome/test/automation/window_proxy.h" | 13 #include "chrome/test/automation/window_proxy.h" |
| 14 #include "chrome/test/ui/ui_test.h" | 14 #include "chrome/test/ui/ui_test.h" |
| 15 #include "gfx/gdi_util.h" | 15 #include "gfx/gdi_util.h" |
| 16 #include "net/url_request/url_request_unittest.h" | 16 #include "net/test/test_server.h" |
| 17 #include "printing/image.h" | 17 #include "printing/image.h" |
| 18 #include "printing/printing_test.h" | 18 #include "printing/printing_test.h" |
| 19 #include "printing/native_metafile.h" | 19 #include "printing/native_metafile.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 using printing::Image; | 23 using printing::Image; |
| 24 | 24 |
| 25 const char kGenerateSwitch[] = "print-layout-generate"; | 25 const char kGenerateSwitch[] = "print-layout-generate"; |
| 26 const wchar_t kDocRoot[] = L"chrome/test/data"; | 26 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // Fails, see http://crbug.com/7721. | 285 // Fails, see http://crbug.com/7721. |
| 286 TEST_F(PrintingLayoutTextTest, FAILS_Complex) { | 286 TEST_F(PrintingLayoutTextTest, FAILS_Complex) { |
| 287 if (IsTestCaseDisabled()) | 287 if (IsTestCaseDisabled()) |
| 288 return; | 288 return; |
| 289 | 289 |
| 290 DismissTheWindow dismisser(base::GetProcId(process())); | 290 DismissTheWindow dismisser(base::GetProcId(process())); |
| 291 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 291 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
| 292 "close_printdlg_thread"); | 292 "close_printdlg_thread"); |
| 293 | 293 |
| 294 // Print a document, check its output. | 294 // Print a document, check its output. |
| 295 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 295 scoped_refptr<net::HTTPTestServer> server( |
| 296 net::HTTPTestServer::CreateServer(kDocRoot)); |
| 296 ASSERT_TRUE(NULL != server.get()); | 297 ASSERT_TRUE(NULL != server.get()); |
| 297 | 298 |
| 298 NavigateToURL(server->TestServerPage("files/printing/test1.html")); | 299 NavigateToURL(server->TestServerPage("files/printing/test1.html")); |
| 299 close_printdlg_thread.Start(); | 300 close_printdlg_thread.Start(); |
| 300 PrintNowTab(); | 301 PrintNowTab(); |
| 301 close_printdlg_thread.Join(); | 302 close_printdlg_thread.Join(); |
| 302 EXPECT_EQ(0., CompareWithResult(L"test1")); | 303 EXPECT_EQ(0., CompareWithResult(L"test1")); |
| 303 } | 304 } |
| 304 | 305 |
| 305 struct TestPool { | 306 struct TestPool { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 316 "files/printing/test4.html", L"test4", | 317 "files/printing/test4.html", L"test4", |
| 317 // TODO(maruel): http://b/1171450 Transparent overlays are drawn opaque | 318 // TODO(maruel): http://b/1171450 Transparent overlays are drawn opaque |
| 318 // "files/printing/test5.html", L"test5", | 319 // "files/printing/test5.html", L"test5", |
| 319 }; | 320 }; |
| 320 | 321 |
| 321 // TODO(maruel:) http://code.google.com/p/chromium/issues/detail?id=7721 | 322 // TODO(maruel:) http://code.google.com/p/chromium/issues/detail?id=7721 |
| 322 TEST_F(PrintingLayoutTestHidden, DISABLED_ManyTimes) { | 323 TEST_F(PrintingLayoutTestHidden, DISABLED_ManyTimes) { |
| 323 if (IsTestCaseDisabled()) | 324 if (IsTestCaseDisabled()) |
| 324 return; | 325 return; |
| 325 | 326 |
| 326 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 327 scoped_refptr<net::HTTPTestServer> server( |
| 328 net::HTTPTestServer::CreateServer(kDocRoot)); |
| 327 ASSERT_TRUE(NULL != server.get()); | 329 ASSERT_TRUE(NULL != server.get()); |
| 328 DismissTheWindow dismisser(base::GetProcId(process())); | 330 DismissTheWindow dismisser(base::GetProcId(process())); |
| 329 | 331 |
| 330 ASSERT_GT(arraysize(kTestPool), 0u); | 332 ASSERT_GT(arraysize(kTestPool), 0u); |
| 331 for (int i = 0; i < arraysize(kTestPool); ++i) { | 333 for (int i = 0; i < arraysize(kTestPool); ++i) { |
| 332 if (i) | 334 if (i) |
| 333 CleanupDumpDirectory(); | 335 CleanupDumpDirectory(); |
| 334 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; | 336 const TestPool& test = kTestPool[i % arraysize(kTestPool)]; |
| 335 NavigateToURL(server->TestServerPage(test.source)); | 337 NavigateToURL(server->TestServerPage(test.source)); |
| 336 base::DelegateSimpleThread close_printdlg_thread1(&dismisser, | 338 base::DelegateSimpleThread close_printdlg_thread1(&dismisser, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 366 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; | 368 EXPECT_EQ(0., CompareWithResult(test.result)) << test.result; |
| 367 } | 369 } |
| 368 } | 370 } |
| 369 | 371 |
| 370 // Prints a popup and immediately closes it. | 372 // Prints a popup and immediately closes it. |
| 371 // TODO(maruel): Reenable it, it causes crashes. | 373 // TODO(maruel): Reenable it, it causes crashes. |
| 372 TEST_F(PrintingLayoutTest, DISABLED_Delayed) { | 374 TEST_F(PrintingLayoutTest, DISABLED_Delayed) { |
| 373 if (IsTestCaseDisabled()) | 375 if (IsTestCaseDisabled()) |
| 374 return; | 376 return; |
| 375 | 377 |
| 376 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 378 scoped_refptr<net::HTTPTestServer> server( |
| 379 net::HTTPTestServer::CreateServer(kDocRoot)); |
| 377 ASSERT_TRUE(NULL != server.get()); | 380 ASSERT_TRUE(NULL != server.get()); |
| 378 | 381 |
| 379 { | 382 { |
| 380 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 383 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 381 ASSERT_TRUE(tab_proxy.get()); | 384 ASSERT_TRUE(tab_proxy.get()); |
| 382 bool is_timeout = true; | 385 bool is_timeout = true; |
| 383 GURL url = server->TestServerPage("files/printing/popup_delayed_print.htm"); | 386 GURL url = server->TestServerPage("files/printing/popup_delayed_print.htm"); |
| 384 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 387 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 385 tab_proxy->NavigateToURL(url)); | 388 tab_proxy->NavigateToURL(url)); |
| 386 | 389 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 400 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) | 403 EXPECT_EQ(0., CompareWithResult(L"popup_delayed_print")) |
| 401 << L"popup_delayed_print"; | 404 << L"popup_delayed_print"; |
| 402 } | 405 } |
| 403 | 406 |
| 404 // Prints a popup and immediately closes it. | 407 // Prints a popup and immediately closes it. |
| 405 // TODO(maruel:) http://code.google.com/p/chromium/issues/detail?id=7721 | 408 // TODO(maruel:) http://code.google.com/p/chromium/issues/detail?id=7721 |
| 406 TEST_F(PrintingLayoutTest, DISABLED_IFrame) { | 409 TEST_F(PrintingLayoutTest, DISABLED_IFrame) { |
| 407 if (IsTestCaseDisabled()) | 410 if (IsTestCaseDisabled()) |
| 408 return; | 411 return; |
| 409 | 412 |
| 410 scoped_refptr<HTTPTestServer> server(HTTPTestServer::CreateServer(kDocRoot)); | 413 scoped_refptr<net::HTTPTestServer> server( |
| 414 net::HTTPTestServer::CreateServer(kDocRoot)); |
| 411 ASSERT_TRUE(NULL != server.get()); | 415 ASSERT_TRUE(NULL != server.get()); |
| 412 | 416 |
| 413 { | 417 { |
| 414 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); | 418 scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); |
| 415 ASSERT_TRUE(tab_proxy.get()); | 419 ASSERT_TRUE(tab_proxy.get()); |
| 416 GURL url = server->TestServerPage("files/printing/iframe.htm"); | 420 GURL url = server->TestServerPage("files/printing/iframe.htm"); |
| 417 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 421 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 418 tab_proxy->NavigateToURL(url)); | 422 tab_proxy->NavigateToURL(url)); |
| 419 | 423 |
| 420 DismissTheWindow dismisser(base::GetProcId(process())); | 424 DismissTheWindow dismisser(base::GetProcId(process())); |
| 421 base::DelegateSimpleThread close_printdlg_thread(&dismisser, | 425 base::DelegateSimpleThread close_printdlg_thread(&dismisser, |
| 422 "close_printdlg_thread"); | 426 "close_printdlg_thread"); |
| 423 close_printdlg_thread.Start(); | 427 close_printdlg_thread.Start(); |
| 424 close_printdlg_thread.Join(); | 428 close_printdlg_thread.Join(); |
| 425 | 429 |
| 426 // Force a navigation elsewhere to verify that it's fine with it. | 430 // Force a navigation elsewhere to verify that it's fine with it. |
| 427 url = server->TestServerPage("files/printing/test1.html"); | 431 url = server->TestServerPage("files/printing/test1.html"); |
| 428 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 432 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 429 tab_proxy->NavigateToURL(url)); | 433 tab_proxy->NavigateToURL(url)); |
| 430 } | 434 } |
| 431 CloseBrowserAndServer(); | 435 CloseBrowserAndServer(); |
| 432 | 436 |
| 433 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; | 437 EXPECT_EQ(0., CompareWithResult(L"iframe")) << L"iframe"; |
| 434 } | 438 } |
| OLD | NEW |