| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "chrome/browser/printing/print_preview_tab_controller.h" | 9 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 10 #include "chrome/browser/printing/print_view_manager.h" | 10 #include "chrome/browser/printing/print_view_manager.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 initiator_tab->print_view_manager()->PrintPreviewNow(); | 51 initiator_tab->print_view_manager()->PrintPreviewNow(); |
| 52 TabContentsWrapper* preview_tab = | 52 TabContentsWrapper* preview_tab = |
| 53 controller->GetOrCreatePreviewTab(initiator_tab); | 53 controller->GetOrCreatePreviewTab(initiator_tab); |
| 54 | 54 |
| 55 EXPECT_NE(initiator_tab, preview_tab); | 55 EXPECT_NE(initiator_tab, preview_tab); |
| 56 EXPECT_EQ(1, browser()->tab_count()); | 56 EXPECT_EQ(1, browser()->tab_count()); |
| 57 EXPECT_EQ(1U, GetConstrainedWindowCount(initiator_tab)); | 57 EXPECT_EQ(1U, GetConstrainedWindowCount(initiator_tab)); |
| 58 | 58 |
| 59 PrintPreviewUI* preview_ui = | 59 PrintPreviewUI* preview_ui = |
| 60 reinterpret_cast<PrintPreviewUI*>(preview_tab->web_ui()); | 60 reinterpret_cast<PrintPreviewUI*>(preview_tab->tab_contents()->web_ui()); |
| 61 ASSERT_TRUE(preview_ui != NULL); | 61 ASSERT_TRUE(preview_ui != NULL); |
| 62 | 62 |
| 63 scoped_refptr<RefCountedBytes> data; | 63 scoped_refptr<RefCountedBytes> data; |
| 64 preview_ui->GetPrintPreviewDataForIndex( | 64 preview_ui->GetPrintPreviewDataForIndex( |
| 65 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, | 65 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, |
| 66 &data); | 66 &data); |
| 67 EXPECT_EQ(NULL, data.get()); | 67 EXPECT_EQ(NULL, data.get()); |
| 68 | 68 |
| 69 std::vector<unsigned char> preview_data(blob1, blob1 + sizeof(blob1)); | 69 std::vector<unsigned char> preview_data(blob1, blob1 + sizeof(blob1)); |
| 70 scoped_refptr<RefCountedBytes> dummy_data(new RefCountedBytes(preview_data)); | 70 scoped_refptr<RefCountedBytes> dummy_data(new RefCountedBytes(preview_data)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 initiator_tab->print_view_manager()->PrintPreviewNow(); | 113 initiator_tab->print_view_manager()->PrintPreviewNow(); |
| 114 TabContentsWrapper* preview_tab = | 114 TabContentsWrapper* preview_tab = |
| 115 controller->GetOrCreatePreviewTab(initiator_tab); | 115 controller->GetOrCreatePreviewTab(initiator_tab); |
| 116 | 116 |
| 117 EXPECT_NE(initiator_tab, preview_tab); | 117 EXPECT_NE(initiator_tab, preview_tab); |
| 118 EXPECT_EQ(1, browser()->tab_count()); | 118 EXPECT_EQ(1, browser()->tab_count()); |
| 119 EXPECT_EQ(1U, GetConstrainedWindowCount(initiator_tab)); | 119 EXPECT_EQ(1U, GetConstrainedWindowCount(initiator_tab)); |
| 120 | 120 |
| 121 PrintPreviewUI* preview_ui = | 121 PrintPreviewUI* preview_ui = |
| 122 reinterpret_cast<PrintPreviewUI*>(preview_tab->web_ui()); | 122 reinterpret_cast<PrintPreviewUI*>(preview_tab->tab_contents()->web_ui()); |
| 123 ASSERT_TRUE(preview_ui != NULL); | 123 ASSERT_TRUE(preview_ui != NULL); |
| 124 | 124 |
| 125 scoped_refptr<RefCountedBytes> data; | 125 scoped_refptr<RefCountedBytes> data; |
| 126 preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data); | 126 preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data); |
| 127 EXPECT_EQ(NULL, data.get()); | 127 EXPECT_EQ(NULL, data.get()); |
| 128 | 128 |
| 129 std::vector<unsigned char> preview_data(blob1, blob1 + sizeof(blob1)); | 129 std::vector<unsigned char> preview_data(blob1, blob1 + sizeof(blob1)); |
| 130 scoped_refptr<RefCountedBytes> dummy_data(new RefCountedBytes(preview_data)); | 130 scoped_refptr<RefCountedBytes> dummy_data(new RefCountedBytes(preview_data)); |
| 131 | 131 |
| 132 preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, | 132 preview_ui->SetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 initiator_tab->print_view_manager()->PrintPreviewNow(); | 182 initiator_tab->print_view_manager()->PrintPreviewNow(); |
| 183 TabContentsWrapper* preview_tab = | 183 TabContentsWrapper* preview_tab = |
| 184 controller->GetOrCreatePreviewTab(initiator_tab); | 184 controller->GetOrCreatePreviewTab(initiator_tab); |
| 185 | 185 |
| 186 EXPECT_NE(initiator_tab, preview_tab); | 186 EXPECT_NE(initiator_tab, preview_tab); |
| 187 EXPECT_EQ(1, browser()->tab_count()); | 187 EXPECT_EQ(1, browser()->tab_count()); |
| 188 EXPECT_EQ(1U, GetConstrainedWindowCount(initiator_tab)); | 188 EXPECT_EQ(1U, GetConstrainedWindowCount(initiator_tab)); |
| 189 | 189 |
| 190 PrintPreviewUI* preview_ui = | 190 PrintPreviewUI* preview_ui = |
| 191 reinterpret_cast<PrintPreviewUI*>(preview_tab->web_ui()); | 191 reinterpret_cast<PrintPreviewUI*>(preview_tab->tab_contents()->web_ui()); |
| 192 ASSERT_TRUE(preview_ui != NULL); | 192 ASSERT_TRUE(preview_ui != NULL); |
| 193 | 193 |
| 194 // Test with invalid |preview_ui_addr|. | 194 // Test with invalid |preview_ui_addr|. |
| 195 bool cancel = false; | 195 bool cancel = false; |
| 196 preview_ui->GetCurrentPrintPreviewStatus("invalid", 0, &cancel); | 196 preview_ui->GetCurrentPrintPreviewStatus("invalid", 0, &cancel); |
| 197 EXPECT_TRUE(cancel); | 197 EXPECT_TRUE(cancel); |
| 198 | 198 |
| 199 const int kFirstRequestId = 1000; | 199 const int kFirstRequestId = 1000; |
| 200 const int kSecondRequestId = 1001; | 200 const int kSecondRequestId = 1001; |
| 201 const std::string preview_ui_addr = preview_ui->GetPrintPreviewUIAddress(); | 201 const std::string preview_ui_addr = preview_ui->GetPrintPreviewUIAddress(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 217 cancel = false; | 217 cancel = false; |
| 218 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kFirstRequestId, | 218 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kFirstRequestId, |
| 219 &cancel); | 219 &cancel); |
| 220 EXPECT_TRUE(cancel); | 220 EXPECT_TRUE(cancel); |
| 221 | 221 |
| 222 cancel = true; | 222 cancel = true; |
| 223 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kSecondRequestId, | 223 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kSecondRequestId, |
| 224 &cancel); | 224 &cancel); |
| 225 EXPECT_FALSE(cancel); | 225 EXPECT_FALSE(cancel); |
| 226 } | 226 } |
| OLD | NEW |