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

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: '' 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 PrintPreviewUI* preview_ui =
41 reinterpret_cast<PrintPreviewUI*>(preview_tab->dom_ui());
42 ASSERT_TRUE(preview_ui != NULL);
43 PrintPreviewUIHTMLSource* html_source = preview_ui->html_source();
44
45 PrintPreviewUIHTMLSource::PrintPreviewData data;
46 html_source->GetPrintPreviewData(&data);
47 EXPECT_EQ(NULL, data.first);
48 EXPECT_EQ(0U, data.second);
49
50 PrintPreviewUIHTMLSource::PrintPreviewData dummy_data =
51 std::make_pair(new base::SharedMemory(), 1234);
52
53 html_source->SetPrintPreviewData(dummy_data);
54 html_source->GetPrintPreviewData(&data);
55 EXPECT_EQ(dummy_data, data);
56
57 // This should not cause any memory leaks.
58 dummy_data.first = new base::SharedMemory();
59 html_source->SetPrintPreviewData(dummy_data);
60 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/print_preview_ui_html_source.cc ('k') | chrome/browser/printing/print_preview_message_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698