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

Side by Side Diff: chrome/browser/dom_ui/print_preview_ui_html_source_unittest.cc

Issue 6334010: Print Preview: Store preview data in the print preview handler.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 9 years, 10 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/shared_memory.h"
7 #include "chrome/browser/dom_ui/print_preview_ui.h"
8 #include "chrome/browser/dom_ui/print_preview_ui_html_source.h"
9 #include "chrome/browser/printing/print_preview_tab_controller.h"
10 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/browser_with_test_window_test.h"
14 #include "chrome/test/testing_profile.h"
15
16 typedef BrowserWithTestWindowTest PrintPreviewUIHTMLSourceTest;
17
18 // Create/Get a preview tab for initiator tab.
19 TEST_F(PrintPreviewUIHTMLSourceTest, PrintPreviewData) {
20 // TODO(thestig) Remove when print preview is enabled by default.
21 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview);
22 ASSERT_TRUE(browser());
23 BrowserList::SetLastActive(browser());
24 ASSERT_TRUE(BrowserList::GetLastActive());
25
26 browser()->NewTab();
27 TabContents* initiator_tab = browser()->GetSelectedTabContents();
28 ASSERT_TRUE(initiator_tab);
29
30 scoped_refptr<printing::PrintPreviewTabController>
31 controller(new printing::PrintPreviewTabController());
32 ASSERT_TRUE(controller);
33
34 TabContents* preview_tab = controller->GetOrCreatePreviewTab(
35 initiator_tab, initiator_tab->controller().window_id().id());
36
37 EXPECT_NE(initiator_tab, preview_tab);
38 EXPECT_EQ(2, browser()->tab_count());
39
40 PrintPreviewUIHTMLSource::PrintPreviewData data;
41 PrintPreviewUIHTMLSource* html_source =
42 reinterpret_cast<PrintPreviewUI*>(preview_tab->dom_ui())->html_source();
43 html_source->GetPrintPreviewData(&data);
44 EXPECT_EQ(NULL, data.first);
45 EXPECT_EQ(0U, data.second);
46
47 PrintPreviewUIHTMLSource::PrintPreviewData dummy_data =
48 std::make_pair(new base::SharedMemory(), 1234);
49
50 html_source->SetPrintPreviewData(dummy_data);
51 html_source->GetPrintPreviewData(&data);
52 EXPECT_EQ(dummy_data, data);
53
54 // This should not cause any memory leaks.
55 dummy_data.first = new base::SharedMemory();
56 html_source->SetPrintPreviewData(dummy_data);
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698