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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_ui.cc

Issue 23054002: Added basic browser test for window.print() from Chrome apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added print preview auto-cancel to avoid test timeouts Created 7 years, 3 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
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 "chrome/browser/ui/webui/print_preview/print_preview_ui.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/id_map.h" 9 #include "base/id_map.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 513
514 if (!initial_preview_start_time_.is_null()) { 514 if (!initial_preview_start_time_.is_null()) {
515 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime", 515 UMA_HISTOGRAM_TIMES("PrintPreview.InitialDisplayTime",
516 base::TimeTicks::Now() - initial_preview_start_time_); 516 base::TimeTicks::Now() - initial_preview_start_time_);
517 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial", 517 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.Initial",
518 expected_pages_count); 518 expected_pages_count);
519 initial_preview_start_time_ = base::TimeTicks(); 519 initial_preview_start_time_ = base::TimeTicks();
520 } 520 }
521 base::FundamentalValue ui_identifier(id_); 521 base::FundamentalValue ui_identifier(id_);
522 base::FundamentalValue ui_preview_request_id(preview_request_id); 522 base::FundamentalValue ui_preview_request_id(preview_request_id);
523 web_ui()->CallJavascriptFunction("updatePrintPreview", ui_identifier, 523 if (AutoCancelForTesting()) {
Vitaly Buka (NO REVIEWS) 2013/08/29 00:10:25 Is possible to avoid js chages and just call OnHid
dharcourt 2013/08/29 04:02:02 Calling OnHidePreviewDialog() doesn't work (the te
524 ui_preview_request_id); 524 web_ui()->CallJavascriptFunction("autoCancelPrintPreviewForTesting");
525 } else {
526 web_ui()->CallJavascriptFunction("updatePrintPreview", ui_identifier,
527 ui_preview_request_id);
528 }
525 } 529 }
526 530
527 void PrintPreviewUI::OnPrintPreviewDialogDestroyed() { 531 void PrintPreviewUI::OnPrintPreviewDialogDestroyed() {
528 handler_->OnPrintPreviewDialogDestroyed(); 532 handler_->OnPrintPreviewDialogDestroyed();
529 } 533 }
530 534
531 void PrintPreviewUI::OnFileSelectionCancelled() { 535 void PrintPreviewUI::OnFileSelectionCancelled() {
532 web_ui()->CallJavascriptFunction("fileSelectionCancelled"); 536 web_ui()->CallJavascriptFunction("fileSelectionCancelled");
533 } 537 }
534 538
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 delegate->OnDialogCloseFromWebUI(); 579 delegate->OnDialogCloseFromWebUI();
576 } 580 }
577 581
578 void PrintPreviewUI::OnReloadPrintersList() { 582 void PrintPreviewUI::OnReloadPrintersList() {
579 web_ui()->CallJavascriptFunction("reloadPrintersList"); 583 web_ui()->CallJavascriptFunction("reloadPrintersList");
580 } 584 }
581 585
582 void PrintPreviewUI::OnPrintPreviewScalingDisabled() { 586 void PrintPreviewUI::OnPrintPreviewScalingDisabled() {
583 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF"); 587 web_ui()->CallJavascriptFunction("printScalingDisabledForSourcePDF");
584 } 588 }
589
590 static bool auto_cancel_for_testing_ = false;
Vitaly Buka (NO REVIEWS) 2013/08/28 01:20:26 auto_cancel_for_testing_ -> g_auto_cancel_for_test
dharcourt 2013/08/28 23:23:57 Done, thanks.
591
592 void PrintPreviewUI::SetAutoCancelForTesting(bool auto_cancel) {
593 auto_cancel_for_testing_ = auto_cancel;
594 }
595
596 bool PrintPreviewUI::AutoCancelForTesting() {
597 return auto_cancel_for_testing_;
598 }
599
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698