OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/ref_counted_memory.h" | 6 #include "base/memory/ref_counted_memory.h" |
7 #include "chrome/browser/printing/print_preview_tab_controller.h" | 7 #include "chrome/browser/printing/print_preview_tab_controller.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/webui/print_preview_ui.h" | 9 #include "chrome/browser/ui/webui/print_preview_ui.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/test/browser_with_test_window_test.h" | 11 #include "chrome/test/browser_with_test_window_test.h" |
12 #include "chrome/test/testing_profile.h" | 12 #include "chrome/test/testing_profile.h" |
13 #include "content/browser/tab_contents/tab_contents.h" | 13 #include "content/browser/tab_contents/tab_contents.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const unsigned char blob1[] = | 17 const unsigned char blob1[] = |
18 "12346102356120394751634516591348710478123649165419234519234512349134"; | 18 "12346102356120394751634516591348710478123649165419234519234512349134"; |
19 | 19 |
20 } // namespace | 20 } // namespace |
21 | 21 |
22 typedef BrowserWithTestWindowTest PrintPreviewUITest; | 22 typedef BrowserWithTestWindowTest PrintPreviewUITest; |
23 | 23 |
24 // Create/Get a preview tab for initiator tab. | 24 // Create/Get a preview tab for initiator tab. |
25 TEST_F(PrintPreviewUITest, PrintPreviewData) { | 25 TEST_F(PrintPreviewUITest, PrintPreviewData) { |
26 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS) || defined(OS_MACOSX) | |
27 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview); | 26 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview); |
28 #endif | |
29 ASSERT_TRUE(browser()); | 27 ASSERT_TRUE(browser()); |
30 BrowserList::SetLastActive(browser()); | 28 BrowserList::SetLastActive(browser()); |
31 ASSERT_TRUE(BrowserList::GetLastActive()); | 29 ASSERT_TRUE(BrowserList::GetLastActive()); |
32 | 30 |
33 browser()->NewTab(); | 31 browser()->NewTab(); |
34 TabContents* initiator_tab = browser()->GetSelectedTabContents(); | 32 TabContents* initiator_tab = browser()->GetSelectedTabContents(); |
35 ASSERT_TRUE(initiator_tab); | 33 ASSERT_TRUE(initiator_tab); |
36 | 34 |
37 scoped_refptr<printing::PrintPreviewTabController> | 35 scoped_refptr<printing::PrintPreviewTabController> |
38 controller(new printing::PrintPreviewTabController()); | 36 controller(new printing::PrintPreviewTabController()); |
(...skipping 18 matching lines...) Expand all Loading... |
57 | 55 |
58 preview_ui->SetPrintPreviewData(dummy_data.get()); | 56 preview_ui->SetPrintPreviewData(dummy_data.get()); |
59 preview_ui->GetPrintPreviewData(&data); | 57 preview_ui->GetPrintPreviewData(&data); |
60 EXPECT_EQ(dummy_data->size(), data->size()); | 58 EXPECT_EQ(dummy_data->size(), data->size()); |
61 EXPECT_EQ(dummy_data.get(), data.get()); | 59 EXPECT_EQ(dummy_data.get(), data.get()); |
62 | 60 |
63 // This should not cause any memory leaks. | 61 // This should not cause any memory leaks. |
64 dummy_data = new RefCountedBytes(); | 62 dummy_data = new RefCountedBytes(); |
65 preview_ui->SetPrintPreviewData(dummy_data); | 63 preview_ui->SetPrintPreviewData(dummy_data); |
66 } | 64 } |
OLD | NEW |