Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/prefs/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
| 6 #include "chrome/browser/printing/print_preview_tab_controller.h" | 6 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 7 #include "chrome/browser/printing/print_view_manager.h" | 7 #include "chrome/browser/printing/print_view_manager.h" |
| 8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/browser_list.h" | 9 #include "chrome/browser/ui/browser_list.h" |
| 10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 11 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" | 13 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/browser_with_test_window_test.h" | 15 #include "chrome/test/base/browser_with_test_window_test.h" |
| 16 #include "content/public/browser/navigation_details.h" | 16 #include "content/public/browser/navigation_details.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
| 19 #include "content/public/browser/plugin_service.h" | |
| 19 #include "content/public/common/url_constants.h" | 20 #include "content/public/common/url_constants.h" |
| 21 #include "webkit/plugins/npapi/mock_plugin_list.h" | |
| 20 | 22 |
| 21 // Test crashes on Aura due to initiator tab's native view having no parent. | 23 // Test crashes on Aura due to initiator tab's native view having no parent. |
| 22 // http://crbug.com/104284 | 24 // http://crbug.com/104284 |
| 23 #if defined(USE_AURA) | 25 #if defined(USE_AURA) |
| 24 #define MAYBE_GetOrCreatePreviewTab DISABLED_GetOrCreatePreviewTab | 26 #define MAYBE_GetOrCreatePreviewTab DISABLED_GetOrCreatePreviewTab |
| 25 #define MAYBE_MultiplePreviewTabs DISABLED_MultiplePreviewTabs | 27 #define MAYBE_MultiplePreviewTabs DISABLED_MultiplePreviewTabs |
| 26 #define MAYBE_ClearInitiatorTabDetails DISABLED_ClearInitiatorTabDetails | 28 #define MAYBE_ClearInitiatorTabDetails DISABLED_ClearInitiatorTabDetails |
| 27 #else | 29 #else |
| 28 #define MAYBE_GetOrCreatePreviewTab GetOrCreatePreviewTab | 30 #define MAYBE_GetOrCreatePreviewTab GetOrCreatePreviewTab |
| 29 #define MAYBE_MultiplePreviewTabs MultiplePreviewTabs | 31 #define MAYBE_MultiplePreviewTabs MultiplePreviewTabs |
| 30 #define MAYBE_ClearInitiatorTabDetails ClearInitiatorTabDetails | 32 #define MAYBE_ClearInitiatorTabDetails ClearInitiatorTabDetails |
| 31 #endif | 33 #endif |
| 32 | 34 |
| 33 class PrintPreviewTabControllerUnitTest : public BrowserWithTestWindowTest { | 35 class PrintPreviewTabControllerUnitTest : public BrowserWithTestWindowTest { |
| 34 public: | 36 public: |
| 35 PrintPreviewTabControllerUnitTest() {} | 37 PrintPreviewTabControllerUnitTest() {} |
|
Peter Kasting
2012/11/15 18:53:50
Nit: While here, can you de-inline these member fu
Bernhard Bauer
2012/11/18 19:15:26
Moved it into a base class.
| |
| 36 virtual ~PrintPreviewTabControllerUnitTest() {} | 38 virtual ~PrintPreviewTabControllerUnitTest() {} |
| 37 | 39 |
| 38 protected: | 40 protected: |
| 39 virtual void SetUp() OVERRIDE { | 41 virtual void SetUp() OVERRIDE { |
| 40 BrowserWithTestWindowTest::SetUp(); | 42 BrowserWithTestWindowTest::SetUp(); |
| 41 | 43 |
| 44 // The PluginService will be destroyed at the end of the test (due to the | |
| 45 // ShadowingAtExitManager in our base class). | |
| 46 content::PluginService::GetInstance()->SetPluginListForTesting( | |
| 47 &plugin_list_); | |
| 48 | |
| 42 profile()->GetPrefs()->SetBoolean(prefs::kPrintPreviewDisabled, false); | 49 profile()->GetPrefs()->SetBoolean(prefs::kPrintPreviewDisabled, false); |
| 43 } | 50 } |
| 51 | |
| 52 private: | |
| 53 webkit::npapi::MockPluginList plugin_list_; | |
|
Peter Kasting
2012/11/15 18:53:50
Nit: DISALLOW_COPY_AND_ASSIGN too
Bernhard Bauer
2012/11/15 23:26:30
Gahh, I always forget these. Note to self: write a
| |
| 44 }; | 54 }; |
| 45 | 55 |
| 46 // Create/Get a preview tab for initiator tab. | 56 // Create/Get a preview tab for initiator tab. |
| 47 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { | 57 TEST_F(PrintPreviewTabControllerUnitTest, MAYBE_GetOrCreatePreviewTab) { |
| 48 // Lets start with one window with one tab. | 58 // Lets start with one window with one tab. |
| 49 EXPECT_EQ(1u, BrowserList::size()); | 59 EXPECT_EQ(1u, BrowserList::size()); |
| 50 EXPECT_EQ(0, browser()->tab_count()); | 60 EXPECT_EQ(0, browser()->tab_count()); |
| 51 chrome::NewTab(browser()); | 61 chrome::NewTab(browser()); |
| 52 EXPECT_EQ(1, browser()->tab_count()); | 62 EXPECT_EQ(1, browser()->tab_count()); |
| 53 | 63 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 tab_controller->EraseInitiatorTabInfo(preview_tab); | 177 tab_controller->EraseInitiatorTabInfo(preview_tab); |
| 168 | 178 |
| 169 // Get the print preview tab for initiator tab. | 179 // Get the print preview tab for initiator tab. |
| 170 TabContents* new_preview_tab = | 180 TabContents* new_preview_tab = |
| 171 tab_controller->GetOrCreatePreviewTab(initiator_tab); | 181 tab_controller->GetOrCreatePreviewTab(initiator_tab); |
| 172 | 182 |
| 173 // New preview tab is created. | 183 // New preview tab is created. |
| 174 EXPECT_EQ(1, browser()->tab_count()); | 184 EXPECT_EQ(1, browser()->tab_count()); |
| 175 EXPECT_NE(new_preview_tab, preview_tab); | 185 EXPECT_NE(new_preview_tab, preview_tab); |
| 176 } | 186 } |
| OLD | NEW |