Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: chrome/browser/printing/printing_layout_browsertest.cc

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

Powered by Google App Engine
This is Rietveld 408576698