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

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

Issue 8659014: Check that we have a focus manager in aura before trying to set focus. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: update, add print preview handler unittest also, same fix. Created 9 years 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
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 "12346102356120394751634516591348710478123649165419234519234512349134"; 24 "12346102356120394751634516591348710478123649165419234519234512349134";
25 25
26 size_t GetConstrainedWindowCount(TabContentsWrapper* tab) { 26 size_t GetConstrainedWindowCount(TabContentsWrapper* tab) {
27 return tab->constrained_window_tab_helper()->constrained_window_count(); 27 return tab->constrained_window_tab_helper()->constrained_window_count();
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 typedef BrowserWithTestWindowTest PrintPreviewUIUnitTest; 32 typedef BrowserWithTestWindowTest PrintPreviewUIUnitTest;
33 33
34 // Test crashes on Aura due to initiator tab's native view having no parent.
35 // http://crbug.com/104284
36 #if defined(USE_AURA)
37 #define MAYBE_PrintPreviewDraftPages DISABLED_PrintPreviewDraftPages
38 #define MAYBE_PrintPreviewData DISABLED_PrintPreviewData
39 #define MAYBE_GetCurrentPrintPreviewStatus DISABLED_GetCurrentPrintPreviewStatus
40 #else
41 #define MAYBE_PrintPreviewData PrintPreviewData
42 #define MAYBE_PrintPreviewDraftPages PrintPreviewDraftPages
43 #define MAYBE_GetCurrentPrintPreviewStatus GetCurrentPrintPreviewStatus
44 #endif
45 // Create/Get a preview tab for initiator tab. 34 // Create/Get a preview tab for initiator tab.
46 TEST_F(PrintPreviewUIUnitTest, MAYBE_PrintPreviewData) { 35 TEST_F(PrintPreviewUIUnitTest, PrintPreviewData) {
47 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview); 36 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview);
48 ASSERT_TRUE(browser()); 37 ASSERT_TRUE(browser());
49 BrowserList::SetLastActive(browser()); 38 BrowserList::SetLastActive(browser());
50 ASSERT_TRUE(BrowserList::GetLastActive()); 39 ASSERT_TRUE(BrowserList::GetLastActive());
51 40
52 browser()->NewTab(); 41 browser()->NewTab();
53 TabContentsWrapper* initiator_tab = 42 TabContentsWrapper* initiator_tab =
54 browser()->GetSelectedTabContentsWrapper(); 43 browser()->GetSelectedTabContentsWrapper();
55 ASSERT_TRUE(initiator_tab); 44 ASSERT_TRUE(initiator_tab);
56 EXPECT_EQ(0U, GetConstrainedWindowCount(initiator_tab)); 45 EXPECT_EQ(0U, GetConstrainedWindowCount(initiator_tab));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // Clear the preview data. 86 // Clear the preview data.
98 preview_ui->ClearAllPreviewData(); 87 preview_ui->ClearAllPreviewData();
99 88
100 preview_ui->GetPrintPreviewDataForIndex( 89 preview_ui->GetPrintPreviewDataForIndex(
101 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, 90 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX,
102 &data); 91 &data);
103 EXPECT_EQ(NULL, data.get()); 92 EXPECT_EQ(NULL, data.get());
104 } 93 }
105 94
106 // Set and get the individual draft pages. 95 // Set and get the individual draft pages.
107 TEST_F(PrintPreviewUIUnitTest, MAYBE_PrintPreviewDraftPages) { 96 TEST_F(PrintPreviewUIUnitTest, PrintPreviewDraftPages) {
108 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS) 97 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
109 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview); 98 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview);
110 #endif 99 #endif
111 ASSERT_TRUE(browser()); 100 ASSERT_TRUE(browser());
112 BrowserList::SetLastActive(browser()); 101 BrowserList::SetLastActive(browser());
113 ASSERT_TRUE(BrowserList::GetLastActive()); 102 ASSERT_TRUE(BrowserList::GetLastActive());
114 103
115 browser()->NewTab(); 104 browser()->NewTab();
116 TabContentsWrapper* initiator_tab = 105 TabContentsWrapper* initiator_tab =
117 browser()->GetSelectedTabContentsWrapper(); 106 browser()->GetSelectedTabContentsWrapper();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_EQ(dummy_data->size(), data->size()); 155 EXPECT_EQ(dummy_data->size(), data->size());
167 EXPECT_EQ(dummy_data.get(), data.get()); 156 EXPECT_EQ(dummy_data.get(), data.get());
168 157
169 // Clear the preview data. 158 // Clear the preview data.
170 preview_ui->ClearAllPreviewData(); 159 preview_ui->ClearAllPreviewData();
171 preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data); 160 preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data);
172 EXPECT_EQ(NULL, data.get()); 161 EXPECT_EQ(NULL, data.get());
173 } 162 }
174 163
175 // Test the browser-side print preview cancellation functionality. 164 // Test the browser-side print preview cancellation functionality.
176 TEST_F(PrintPreviewUIUnitTest, MAYBE_GetCurrentPrintPreviewStatus) { 165 TEST_F(PrintPreviewUIUnitTest, GetCurrentPrintPreviewStatus) {
177 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS) 166 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS)
178 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview); 167 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview);
179 #endif 168 #endif
180 ASSERT_TRUE(browser()); 169 ASSERT_TRUE(browser());
181 BrowserList::SetLastActive(browser()); 170 BrowserList::SetLastActive(browser());
182 ASSERT_TRUE(BrowserList::GetLastActive()); 171 ASSERT_TRUE(BrowserList::GetLastActive());
183 172
184 browser()->NewTab(); 173 browser()->NewTab();
185 TabContentsWrapper* initiator_tab = 174 TabContentsWrapper* initiator_tab =
186 browser()->GetSelectedTabContentsWrapper(); 175 browser()->GetSelectedTabContentsWrapper();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 cancel = false; 217 cancel = false;
229 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kFirstRequestId, 218 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kFirstRequestId,
230 &cancel); 219 &cancel);
231 EXPECT_TRUE(cancel); 220 EXPECT_TRUE(cancel);
232 221
233 cancel = true; 222 cancel = true;
234 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kSecondRequestId, 223 preview_ui->GetCurrentPrintPreviewStatus(preview_ui_addr, kSecondRequestId,
235 &cancel); 224 &cancel);
236 EXPECT_FALSE(cancel); 225 EXPECT_FALSE(cancel);
237 } 226 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698