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

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

Issue 7063030: PrintPreview: Print Preview is not staying associated with initiator renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 6 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
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/printing/print_preview_tab_controller.h"
8 #include "chrome/browser/ui/browser_list.h"
9 #include "chrome/browser/ui/webui/print_preview_ui.h"
10 #include "chrome/browser/ui/webui/print_preview_ui_html_source.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/test/browser_with_test_window_test.h"
13 #include "chrome/test/testing_profile.h"
14 #include "content/browser/tab_contents/tab_contents.h"
15
16 typedef BrowserWithTestWindowTest PrintPreviewUIHTMLSourceTest;
17
18 // Create/Get a preview tab for initiator tab.
19 TEST_F(PrintPreviewUIHTMLSourceTest, PrintPreviewData) {
20 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
21 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview);
22 #endif
23 ASSERT_TRUE(browser());
24 BrowserList::SetLastActive(browser());
25 ASSERT_TRUE(BrowserList::GetLastActive());
26
27 browser()->NewTab();
28 TabContents* initiator_tab = browser()->GetSelectedTabContents();
29 ASSERT_TRUE(initiator_tab);
30
31 scoped_refptr<printing::PrintPreviewTabController>
32 controller(new printing::PrintPreviewTabController());
33 ASSERT_TRUE(controller);
34
35 TabContents* preview_tab = controller->GetOrCreatePreviewTab(initiator_tab);
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->web_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/ui/webui/print_preview_ui_html_source.cc ('k') | chrome/browser/ui/webui/print_preview_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698