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

Unified Diff: chrome/browser/ui/webui/print_preview_ui_unittest.cc

Issue 7747033: Merge 97702, 97820, 97976 (Closed) Base URL: svn://chrome-svn/chrome/branches/835/src/
Patch Set: Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/print_preview_ui.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/print_preview_ui_unittest.cc
===================================================================
--- chrome/browser/ui/webui/print_preview_ui_unittest.cc (revision 98330)
+++ chrome/browser/ui/webui/print_preview_ui_unittest.cc (working copy)
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <vector>
+
#include "base/command_line.h"
#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
@@ -142,3 +144,63 @@
preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data);
EXPECT_EQ(NULL, data.get());
}
+
+// Test the browser-side print preview cancellation functionality.
+TEST_F(PrintPreviewUITest, GetCurrentPrintPreviewStatus) {
+#if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
+ CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview);
+#endif
+ ASSERT_TRUE(browser());
+ BrowserList::SetLastActive(browser());
+ ASSERT_TRUE(BrowserList::GetLastActive());
+
+ browser()->NewTab();
+ TabContents* initiator_tab = browser()->GetSelectedTabContents();
+ ASSERT_TRUE(initiator_tab);
+
+ scoped_refptr<printing::PrintPreviewTabController>
+ controller(new printing::PrintPreviewTabController());
+ ASSERT_TRUE(controller);
+
+ TabContents* preview_tab = controller->GetOrCreatePreviewTab(initiator_tab);
+
+ EXPECT_NE(initiator_tab, preview_tab);
+ EXPECT_EQ(2, browser()->tab_count());
+
+ PrintPreviewUI* preview_ui =
+ reinterpret_cast<PrintPreviewUI*>(preview_tab->web_ui());
+ ASSERT_TRUE(preview_ui != NULL);
+
+ // Test with invalid |preview_ui_addr|.
+ bool cancel = false;
+ preview_ui->GetCurrentPrintPreviewStatus("invalid", 0, &cancel);
+ EXPECT_TRUE(cancel);
+
+ const int kFirstRequestId = 1000;
+ const int kSecondRequestId = 1001;
+ const std::string preview_ui_addr = preview_ui->GetPrintPreviewUIAddress();
+
+ // Test with kFirstRequestId.
+ preview_ui->OnPrintPreviewRequest(kFirstRequestId);
+ cancel = true;
+ preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kFirstRequestId,
+ &cancel);
+ EXPECT_FALSE(cancel);
+
+ cancel = false;
+ preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kSecondRequestId,
+ &cancel);
+ EXPECT_TRUE(cancel);
+
+ // Test with kSecondRequestId.
+ preview_ui->OnPrintPreviewRequest(kSecondRequestId);
+ cancel = false;
+ preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kFirstRequestId,
+ &cancel);
+ EXPECT_TRUE(cancel);
+
+ cancel = true;
+ preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kSecondRequestId,
+ &cancel);
+ EXPECT_FALSE(cancel);
+}
« no previous file with comments | « chrome/browser/ui/webui/print_preview_ui.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698