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

Side by Side Diff: chrome/browser/ui/webui/print_preview_handler_unittest.cc

Issue 7799019: Print Preview: Add a test for activating the initiator tab on print. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: reinterpret_cast -> static_cast Created 9 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/json/json_writer.h"
7 #include "base/values.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/printing/background_printing_manager.h"
10 #include "chrome/browser/printing/print_preview_tab_controller.h"
11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
13 #include "chrome/browser/ui/webui/print_preview_handler.h"
14 #include "chrome/browser/ui/webui/print_preview_ui.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/base/browser_with_test_window_test.h"
17 #include "content/browser/tab_contents/tab_contents.h"
18 #include "printing/print_job_constants.h"
19
20 typedef BrowserWithTestWindowTest PrintPreviewHandlerTest;
21
22 // When users hit print in the print preview tab, the print preview tab hides
23 // and the focus should return to the initiator tab.
24 TEST_F(PrintPreviewHandlerTest, ActivateInitiatorTabOnPrint) {
25 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
26 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview);
27 #endif
28 ASSERT_TRUE(browser());
29 BrowserList::SetLastActive(browser());
30 ASSERT_TRUE(BrowserList::GetLastActive());
31
32 browser()->NewTab();
33 TabContentsWrapper* initiator_tab =
34 browser()->GetSelectedTabContentsWrapper();
35 ASSERT_TRUE(initiator_tab);
36
37 printing::PrintPreviewTabController* controller =
38 printing::PrintPreviewTabController::GetInstance();
39 ASSERT_TRUE(controller);
40
41 TabContentsWrapper* preview_tab =
42 controller->GetOrCreatePreviewTab(initiator_tab);
43 EXPECT_EQ(2, browser()->tab_count());
44
45 browser()->NewTab();
46 EXPECT_EQ(3, browser()->tab_count());
47
48 PrintPreviewUI* preview_ui =
49 static_cast<PrintPreviewUI*>(preview_tab->web_ui());
50 ASSERT_TRUE(preview_ui);
51
52 // Set the minimal dummy settings to make the HandlePrint() code happy.
53 DictionaryValue value;
54 value.SetBoolean(printing::kSettingColor, false);
55 value.SetBoolean(printing::kSettingPrintToPDF, false);
56
57 // Put |value| in to |args| as a JSON string.
58 std::string json_string;
59 base::JSONWriter::Write(&value, false, &json_string);
60 ListValue args;
61 args.Append(new StringValue(json_string)); // |args| takes ownership.
62 preview_ui->handler_->HandlePrint(&args);
63
64 EXPECT_EQ(2, browser()->tab_count());
65 EXPECT_EQ(initiator_tab, browser()->GetSelectedTabContentsWrapper());
kmadhusu 2011/08/31 17:24:39 Can you also verify that background printing manag
Lei Zhang 2011/08/31 21:43:08 Done.
66 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | chrome/browser/ui/webui/print_preview_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698