| 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/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/printing/background_printing_manager.h" | 9 #include "chrome/browser/printing/background_printing_manager.h" |
| 10 #include "chrome/browser/printing/print_preview_tab_controller.h" | 10 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 private: | 142 private: |
| 143 void ClearStickySettings() { | 143 void ClearStickySettings() { |
| 144 PrintPreviewHandler::last_used_margins_type_ = printing::DEFAULT_MARGINS; | 144 PrintPreviewHandler::last_used_margins_type_ = printing::DEFAULT_MARGINS; |
| 145 delete PrintPreviewHandler::last_used_page_size_margins_; | 145 delete PrintPreviewHandler::last_used_page_size_margins_; |
| 146 PrintPreviewHandler::last_used_page_size_margins_ = NULL; | 146 PrintPreviewHandler::last_used_page_size_margins_ = NULL; |
| 147 } | 147 } |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 // Test crashs on TouchUI due to initiator tab's native view having no parent. | 150 // Test crashs on TouchUI due to initiator tab's native view having no parent. |
| 151 // http://crbug.com/104284 | 151 // http://crbug.com/104284 |
| 152 #if defined(TOUCH_UI) | 152 // Crashes on Aura due to no FocusManager. |
| 153 // http://crbug.com/105186 |
| 154 #if defined(TOUCH_UI) || defined(USE_AURA) |
| 153 #define MAYBE_StickyMarginsCustom DISABLED_StickyMarginsCustom | 155 #define MAYBE_StickyMarginsCustom DISABLED_StickyMarginsCustom |
| 154 #else | 156 #else |
| 155 #define MAYBE_StickyMarginsCustom StickyMarginsCustom | 157 #define MAYBE_StickyMarginsCustom StickyMarginsCustom |
| 156 #endif | 158 #endif |
| 157 // Tests that margin settings are saved correctly when printing with custom | 159 // Tests that margin settings are saved correctly when printing with custom |
| 158 // margins selected. | 160 // margins selected. |
| 159 TEST_F(PrintPreviewHandlerTest, MAYBE_StickyMarginsCustom) { | 161 TEST_F(PrintPreviewHandlerTest, MAYBE_StickyMarginsCustom) { |
| 160 const double kMarginTop = 25.5; | 162 const double kMarginTop = 25.5; |
| 161 const double kMarginRight = 26.5; | 163 const double kMarginRight = 26.5; |
| 162 const double kMarginBottom = 27.5; | 164 const double kMarginBottom = 27.5; |
| 163 const double kMarginLeft = 28.5; | 165 const double kMarginLeft = 28.5; |
| 164 RequestPrintWithCustomMargins( | 166 RequestPrintWithCustomMargins( |
| 165 kMarginTop, kMarginRight, kMarginBottom, kMarginLeft); | 167 kMarginTop, kMarginRight, kMarginBottom, kMarginLeft); |
| 166 EXPECT_EQ(1, browser()->tab_count()); | 168 EXPECT_EQ(1, browser()->tab_count()); |
| 167 | 169 |
| 168 // Checking that sticky settings were saved correctly. | 170 // Checking that sticky settings were saved correctly. |
| 169 EXPECT_EQ(PrintPreviewHandler::last_used_color_model_, printing::COLOR); | 171 EXPECT_EQ(PrintPreviewHandler::last_used_color_model_, printing::COLOR); |
| 170 EXPECT_EQ(PrintPreviewHandler::last_used_margins_type_, | 172 EXPECT_EQ(PrintPreviewHandler::last_used_margins_type_, |
| 171 printing::CUSTOM_MARGINS); | 173 printing::CUSTOM_MARGINS); |
| 172 ASSERT_TRUE(PrintPreviewHandler::last_used_page_size_margins_); | 174 ASSERT_TRUE(PrintPreviewHandler::last_used_page_size_margins_); |
| 173 CheckCustomMargins(kMarginTop, kMarginRight, kMarginBottom, kMarginLeft); | 175 CheckCustomMargins(kMarginTop, kMarginRight, kMarginBottom, kMarginLeft); |
| 174 } | 176 } |
| 175 | 177 |
| 176 // http://crbug.com/104284 | 178 // http://crbug.com/104284 |
| 177 #if defined(TOUCH_UI) | 179 // http://crbug.com/105186 |
| 180 #if defined(TOUCH_UI) || defined(USE_AURA) |
| 178 #define MAYBE_StickyMarginsDefault DISABLED_StickyMarginsDefault | 181 #define MAYBE_StickyMarginsDefault DISABLED_StickyMarginsDefault |
| 179 #else | 182 #else |
| 180 #define MAYBE_StickyMarginsDefault StickyMarginsDefault | 183 #define MAYBE_StickyMarginsDefault StickyMarginsDefault |
| 181 #endif | 184 #endif |
| 182 // Tests that margin settings are saved correctly when printing with default | 185 // Tests that margin settings are saved correctly when printing with default |
| 183 // margins selected. | 186 // margins selected. |
| 184 TEST_F(PrintPreviewHandlerTest, MAYBE_StickyMarginsDefault) { | 187 TEST_F(PrintPreviewHandlerTest, MAYBE_StickyMarginsDefault) { |
| 185 RequestPrintWithDefaultMargins(); | 188 RequestPrintWithDefaultMargins(); |
| 186 EXPECT_EQ(1, browser()->tab_count()); | 189 EXPECT_EQ(1, browser()->tab_count()); |
| 187 | 190 |
| 188 // Checking that sticky settings were saved correctly. | 191 // Checking that sticky settings were saved correctly. |
| 189 EXPECT_EQ(PrintPreviewHandler::last_used_color_model_, printing::COLOR); | 192 EXPECT_EQ(PrintPreviewHandler::last_used_color_model_, printing::COLOR); |
| 190 EXPECT_EQ(PrintPreviewHandler::last_used_margins_type_, | 193 EXPECT_EQ(PrintPreviewHandler::last_used_margins_type_, |
| 191 printing::DEFAULT_MARGINS); | 194 printing::DEFAULT_MARGINS); |
| 192 ASSERT_FALSE(PrintPreviewHandler::last_used_page_size_margins_); | 195 ASSERT_FALSE(PrintPreviewHandler::last_used_page_size_margins_); |
| 193 } | 196 } |
| 194 | 197 |
| 195 // http://crbug.com/104284 | 198 // http://crbug.com/104284 |
| 196 #if defined(TOUCH_UI) | 199 // http://crbug.com/105186 |
| 200 #if defined(TOUCH_UI) || defined(USE_AURA) |
| 197 #define MAYBE_StickyMarginsCustomThenDefault \ | 201 #define MAYBE_StickyMarginsCustomThenDefault \ |
| 198 DISABLED_StickyMarginsCustomThenDefault | 202 DISABLED_StickyMarginsCustomThenDefault |
| 199 #else | 203 #else |
| 200 #define MAYBE_StickyMarginsCustomThenDefault StickyMarginsCustomThenDefault | 204 #define MAYBE_StickyMarginsCustomThenDefault StickyMarginsCustomThenDefault |
| 201 #endif | 205 #endif |
| 202 // Tests that margin settings are saved correctly when printing with custom | 206 // Tests that margin settings are saved correctly when printing with custom |
| 203 // margins selected and then again with default margins selected. | 207 // margins selected and then again with default margins selected. |
| 204 TEST_F(PrintPreviewHandlerTest, MAYBE_StickyMarginsCustomThenDefault) { | 208 TEST_F(PrintPreviewHandlerTest, MAYBE_StickyMarginsCustomThenDefault) { |
| 205 const double kMarginTop = 125.5; | 209 const double kMarginTop = 125.5; |
| 206 const double kMarginRight = 126.5; | 210 const double kMarginRight = 126.5; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 220 | 224 |
| 221 // Checking that sticky settings were saved correctly. | 225 // Checking that sticky settings were saved correctly. |
| 222 EXPECT_EQ(PrintPreviewHandler::last_used_color_model_, printing::COLOR); | 226 EXPECT_EQ(PrintPreviewHandler::last_used_color_model_, printing::COLOR); |
| 223 EXPECT_EQ(PrintPreviewHandler::last_used_margins_type_, | 227 EXPECT_EQ(PrintPreviewHandler::last_used_margins_type_, |
| 224 printing::DEFAULT_MARGINS); | 228 printing::DEFAULT_MARGINS); |
| 225 ASSERT_TRUE(PrintPreviewHandler::last_used_page_size_margins_); | 229 ASSERT_TRUE(PrintPreviewHandler::last_used_page_size_margins_); |
| 226 CheckCustomMargins(kMarginTop, kMarginRight, kMarginBottom, kMarginLeft); | 230 CheckCustomMargins(kMarginTop, kMarginRight, kMarginBottom, kMarginLeft); |
| 227 } | 231 } |
| 228 | 232 |
| 229 // http://crbug.com/104284 | 233 // http://crbug.com/104284 |
| 230 #if defined(TOUCH_UI) | 234 // http://crbug.com/105186 |
| 235 #if defined(TOUCH_UI) || defined(USE_AURA) |
| 231 #define MAYBE_GetLastUsedMarginSettingsCustom \ | 236 #define MAYBE_GetLastUsedMarginSettingsCustom \ |
| 232 DISABLED_GetLastUsedMarginSettingsCustom | 237 DISABLED_GetLastUsedMarginSettingsCustom |
| 233 #else | 238 #else |
| 234 #define MAYBE_GetLastUsedMarginSettingsCustom GetLastUsedMarginSettingsCustom | 239 #define MAYBE_GetLastUsedMarginSettingsCustom GetLastUsedMarginSettingsCustom |
| 235 #endif | 240 #endif |
| 236 // Tests that margin settings are retrieved correctly after printing with custom | 241 // Tests that margin settings are retrieved correctly after printing with custom |
| 237 // margins. | 242 // margins. |
| 238 TEST_F(PrintPreviewHandlerTest, MAYBE_GetLastUsedMarginSettingsCustom) { | 243 TEST_F(PrintPreviewHandlerTest, MAYBE_GetLastUsedMarginSettingsCustom) { |
| 239 const double kMarginTop = 125.5; | 244 const double kMarginTop = 125.5; |
| 240 const double kMarginRight = 126.5; | 245 const double kMarginRight = 126.5; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 257 EXPECT_EQ(kMarginRight, margin_value); | 262 EXPECT_EQ(kMarginRight, margin_value); |
| 258 EXPECT_TRUE(initial_settings.GetDouble(printing::kSettingMarginBottom, | 263 EXPECT_TRUE(initial_settings.GetDouble(printing::kSettingMarginBottom, |
| 259 &margin_value)); | 264 &margin_value)); |
| 260 EXPECT_EQ(kMarginBottom, margin_value); | 265 EXPECT_EQ(kMarginBottom, margin_value); |
| 261 EXPECT_TRUE(initial_settings.GetDouble(printing::kSettingMarginLeft, | 266 EXPECT_TRUE(initial_settings.GetDouble(printing::kSettingMarginLeft, |
| 262 &margin_value)); | 267 &margin_value)); |
| 263 EXPECT_EQ(kMarginLeft, margin_value); | 268 EXPECT_EQ(kMarginLeft, margin_value); |
| 264 } | 269 } |
| 265 | 270 |
| 266 // http://crbug.com/104284 | 271 // http://crbug.com/104284 |
| 267 #if defined(TOUCH_UI) | 272 // http://crbug.com/105186 |
| 273 #if defined(TOUCH_UI) || defined(USE_AURA) |
| 268 #define MAYBE_GetLastUsedMarginSettingsDefault \ | 274 #define MAYBE_GetLastUsedMarginSettingsDefault \ |
| 269 DISABLED_GetLastUsedMarginSettingsDefault | 275 DISABLED_GetLastUsedMarginSettingsDefault |
| 270 #else | 276 #else |
| 271 #define MAYBE_GetLastUsedMarginSettingsDefault GetLastUsedMarginSettingsDefault | 277 #define MAYBE_GetLastUsedMarginSettingsDefault GetLastUsedMarginSettingsDefault |
| 272 #endif | 278 #endif |
| 273 // Tests that margin settings are retrieved correctly after printing with | 279 // Tests that margin settings are retrieved correctly after printing with |
| 274 // default margins. | 280 // default margins. |
| 275 TEST_F(PrintPreviewHandlerTest, MAYBE_GetLastUsedMarginSettingsDefault) { | 281 TEST_F(PrintPreviewHandlerTest, MAYBE_GetLastUsedMarginSettingsDefault) { |
| 276 RequestPrintWithDefaultMargins(); | 282 RequestPrintWithDefaultMargins(); |
| 277 base::DictionaryValue initial_settings; | 283 base::DictionaryValue initial_settings; |
| 278 preview_ui_->handler_->GetLastUsedMarginSettings(&initial_settings); | 284 preview_ui_->handler_->GetLastUsedMarginSettings(&initial_settings); |
| 279 int margins_type; | 285 int margins_type; |
| 280 EXPECT_TRUE(initial_settings.GetInteger(printing::kSettingMarginsType, | 286 EXPECT_TRUE(initial_settings.GetInteger(printing::kSettingMarginsType, |
| 281 &margins_type)); | 287 &margins_type)); |
| 282 EXPECT_EQ(margins_type, printing::DEFAULT_MARGINS); | 288 EXPECT_EQ(margins_type, printing::DEFAULT_MARGINS); |
| 283 double margin_value; | 289 double margin_value; |
| 284 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginTop, | 290 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginTop, |
| 285 &margin_value)); | 291 &margin_value)); |
| 286 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginRight, | 292 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginRight, |
| 287 &margin_value)); | 293 &margin_value)); |
| 288 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginBottom, | 294 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginBottom, |
| 289 &margin_value)); | 295 &margin_value)); |
| 290 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginLeft, | 296 EXPECT_FALSE(initial_settings.GetDouble(printing::kSettingMarginLeft, |
| 291 &margin_value)); | 297 &margin_value)); |
| 292 } | 298 } |
| OLD | NEW |