diff options
author | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-01 20:44:26 +0000 |
---|---|---|
committer | creis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-01 20:44:26 +0000 |
commit | 1fe88ff2d6f84f181e5a7942a06ab7a2d899ef89 (patch) | |
tree | bce4a70fc1c9293e033bec845c80f893e7cf1a06 | |
parent | a5c0fd98173a9a4fc5674d44afc1594996fc05e0 (diff) | |
download | chromium_src-1fe88ff2d6f84f181e5a7942a06ab7a2d899ef89.zip chromium_src-1fe88ff2d6f84f181e5a7942a06ab7a2d899ef89.tar.gz chromium_src-1fe88ff2d6f84f181e5a7942a06ab7a2d899ef89.tar.bz2 |
Revert 99149 - Print Preview: Add a test for activating the initiator tab on print.
BUG=none
TEST=included
Review URL: http://codereview.chromium.org/7799019
TBR=thestig@chromium.org
Review URL: http://codereview.chromium.org/7831019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99240 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/printing/print_preview_tab_controller_browsertest.cc | 12 | ||||
-rw-r--r-- | chrome/browser/printing/print_preview_tab_controller_unittest.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview_handler.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview_handler_unittest.cc | 69 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview_ui.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview_ui_unittest.cc | 24 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | chrome/test/base/testing_browser_process.cc | 5 | ||||
-rw-r--r-- | chrome/test/base/testing_browser_process.h | 4 |
9 files changed, 28 insertions, 108 deletions
diff --git a/chrome/browser/printing/print_preview_tab_controller_browsertest.cc b/chrome/browser/printing/print_preview_tab_controller_browsertest.cc index 0a9f564..d8b4858 100644 --- a/chrome/browser/printing/print_preview_tab_controller_browsertest.cc +++ b/chrome/browser/printing/print_preview_tab_controller_browsertest.cc @@ -33,8 +33,8 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewTabControllerBrowserTest, browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(initiator_tab); - printing::PrintPreviewTabController* tab_controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + tab_controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(tab_controller); // Get the preview tab for initiator tab. @@ -85,8 +85,8 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewTabControllerBrowserTest, browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(initiator_tab); - printing::PrintPreviewTabController* tab_controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + tab_controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(tab_controller); // Get the preview tab for initiator tab. @@ -136,8 +136,8 @@ IN_PROC_BROWSER_TEST_F(PrintPreviewTabControllerBrowserTest, browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(initiator_tab); - printing::PrintPreviewTabController* tab_controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + tab_controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(tab_controller); // Get the preview tab for initiator tab. diff --git a/chrome/browser/printing/print_preview_tab_controller_unittest.cc b/chrome/browser/printing/print_preview_tab_controller_unittest.cc index e18a326..beb54b2 100644 --- a/chrome/browser/printing/print_preview_tab_controller_unittest.cc +++ b/chrome/browser/printing/print_preview_tab_controller_unittest.cc @@ -33,8 +33,8 @@ TEST_F(PrintPreviewTabControllerUnitTest, GetOrCreatePreviewTab) { TabContentsWrapper* initiator_tab = browser()->GetSelectedTabContentsWrapper(); - printing::PrintPreviewTabController* tab_controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + tab_controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(tab_controller); // Get the preview tab for initiator tab. @@ -73,8 +73,8 @@ TEST_F(PrintPreviewTabControllerUnitTest, TitleAfterReload) { TabContentsWrapper* initiator_tab = browser()->GetSelectedTabContentsWrapper(); - printing::PrintPreviewTabController* tab_controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + tab_controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(tab_controller); // Get the preview tab for initiator tab. @@ -128,8 +128,8 @@ TEST_F(PrintPreviewTabControllerUnitTest, MultiplePreviewTabs) { ASSERT_TRUE(tab_contents_2); EXPECT_EQ(2, browser()->tab_count()); - printing::PrintPreviewTabController* tab_controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + tab_controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(tab_controller); // Create preview tab for |tab_contents_1| @@ -180,8 +180,8 @@ TEST_F(PrintPreviewTabControllerUnitTest, ClearInitiatorTabDetails) { TabContentsWrapper* initiator_tab = browser()->GetSelectedTabContentsWrapper(); - printing::PrintPreviewTabController* tab_controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + tab_controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(tab_controller); // Get the preview tab for initiator tab. diff --git a/chrome/browser/ui/webui/print_preview_handler.h b/chrome/browser/ui/webui/print_preview_handler.h index cd6917d..7d6ce16 100644 --- a/chrome/browser/ui/webui/print_preview_handler.h +++ b/chrome/browser/ui/webui/print_preview_handler.h @@ -65,8 +65,6 @@ class PrintPreviewHandler : public WebUIMessageHandler, private: friend class PrintSystemTaskProxy; - FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, - ActivateInitiatorTabOnPrint); TabContentsWrapper* preview_tab_wrapper() const; TabContents* preview_tab() const; diff --git a/chrome/browser/ui/webui/print_preview_handler_unittest.cc b/chrome/browser/ui/webui/print_preview_handler_unittest.cc deleted file mode 100644 index 45f47ec..0000000 --- a/chrome/browser/ui/webui/print_preview_handler_unittest.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/command_line.h" -#include "base/json/json_writer.h" -#include "base/values.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/printing/background_printing_manager.h" -#include "chrome/browser/printing/print_preview_tab_controller.h" -#include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/webui/print_preview_handler.h" -#include "chrome/browser/ui/webui/print_preview_ui.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/test/base/browser_with_test_window_test.h" -#include "printing/print_job_constants.h" - -typedef BrowserWithTestWindowTest PrintPreviewHandlerTest; - -// When users hit print in the print preview tab, the print preview tab hides -// and the focus should return to the initiator tab. -TEST_F(PrintPreviewHandlerTest, ActivateInitiatorTabOnPrint) { -#if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS) - CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnablePrintPreview); -#endif - ASSERT_TRUE(browser()); - BrowserList::SetLastActive(browser()); - ASSERT_TRUE(BrowserList::GetLastActive()); - - browser()->NewTab(); - TabContentsWrapper* initiator_tab = - browser()->GetSelectedTabContentsWrapper(); - ASSERT_TRUE(initiator_tab); - - printing::PrintPreviewTabController* controller = - printing::PrintPreviewTabController::GetInstance(); - ASSERT_TRUE(controller); - - TabContentsWrapper* preview_tab = - controller->GetOrCreatePreviewTab(initiator_tab); - EXPECT_EQ(2, browser()->tab_count()); - - browser()->NewTab(); - EXPECT_EQ(3, browser()->tab_count()); - - PrintPreviewUI* preview_ui = - static_cast<PrintPreviewUI*>(preview_tab->web_ui()); - ASSERT_TRUE(preview_ui); - - // Set the minimal dummy settings to make the HandlePrint() code happy. - DictionaryValue value; - value.SetBoolean(printing::kSettingColor, false); - value.SetBoolean(printing::kSettingPrintToPDF, false); - - // Put |value| in to |args| as a JSON string. - std::string json_string; - base::JSONWriter::Write(&value, false, &json_string); - ListValue args; - args.Append(new StringValue(json_string)); // |args| takes ownership. - preview_ui->handler_->HandlePrint(&args); - - EXPECT_EQ(2, browser()->tab_count()); - EXPECT_EQ(initiator_tab, browser()->GetSelectedTabContentsWrapper()); - - printing::BackgroundPrintingManager* bg_printing_manager = - g_browser_process->background_printing_manager(); - EXPECT_TRUE(bg_printing_manager->HasPrintPreviewTab(preview_tab)); -} diff --git a/chrome/browser/ui/webui/print_preview_ui.h b/chrome/browser/ui/webui/print_preview_ui.h index 7e3bf76..52a52f3 100644 --- a/chrome/browser/ui/webui/print_preview_ui.h +++ b/chrome/browser/ui/webui/print_preview_ui.h @@ -112,8 +112,6 @@ class PrintPreviewUI : public ChromeWebUI { void OnCancelPendingPreviewRequest(); private: - FRIEND_TEST_ALL_PREFIXES(PrintPreviewHandlerTest, - ActivateInitiatorTabOnPrint); FRIEND_TEST_ALL_PREFIXES(PrintPreviewTabControllerUnitTest, TitleAfterReload); diff --git a/chrome/browser/ui/webui/print_preview_ui_unittest.cc b/chrome/browser/ui/webui/print_preview_ui_unittest.cc index d05b5dd..a7060cc 100644 --- a/chrome/browser/ui/webui/print_preview_ui_unittest.cc +++ b/chrome/browser/ui/webui/print_preview_ui_unittest.cc @@ -37,8 +37,8 @@ TEST_F(PrintPreviewUITest, PrintPreviewData) { browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(initiator_tab); - printing::PrintPreviewTabController* controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(controller); TabContentsWrapper* preview_tab = @@ -48,8 +48,8 @@ TEST_F(PrintPreviewUITest, PrintPreviewData) { EXPECT_EQ(2, browser()->tab_count()); PrintPreviewUI* preview_ui = - static_cast<PrintPreviewUI*>(preview_tab->web_ui()); - ASSERT_TRUE(preview_ui); + reinterpret_cast<PrintPreviewUI*>(preview_tab->web_ui()); + ASSERT_TRUE(preview_ui != NULL); scoped_refptr<RefCountedBytes> data; preview_ui->GetPrintPreviewDataForIndex( @@ -97,8 +97,8 @@ TEST_F(PrintPreviewUITest, PrintPreviewDraftPages) { browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(initiator_tab); - printing::PrintPreviewTabController* controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(controller); TabContentsWrapper* preview_tab = @@ -108,8 +108,8 @@ TEST_F(PrintPreviewUITest, PrintPreviewDraftPages) { EXPECT_EQ(2, browser()->tab_count()); PrintPreviewUI* preview_ui = - static_cast<PrintPreviewUI*>(preview_tab->web_ui()); - ASSERT_TRUE(preview_ui); + reinterpret_cast<PrintPreviewUI*>(preview_tab->web_ui()); + ASSERT_TRUE(preview_ui != NULL); scoped_refptr<RefCountedBytes> data; preview_ui->GetPrintPreviewDataForIndex(printing::FIRST_PAGE_INDEX, &data); @@ -164,8 +164,8 @@ TEST_F(PrintPreviewUITest, GetCurrentPrintPreviewStatus) { browser()->GetSelectedTabContentsWrapper(); ASSERT_TRUE(initiator_tab); - printing::PrintPreviewTabController* controller = - printing::PrintPreviewTabController::GetInstance(); + scoped_refptr<printing::PrintPreviewTabController> + controller(new printing::PrintPreviewTabController()); ASSERT_TRUE(controller); TabContentsWrapper* preview_tab = @@ -175,8 +175,8 @@ TEST_F(PrintPreviewUITest, GetCurrentPrintPreviewStatus) { EXPECT_EQ(2, browser()->tab_count()); PrintPreviewUI* preview_ui = - static_cast<PrintPreviewUI*>(preview_tab->web_ui()); - ASSERT_TRUE(preview_ui); + reinterpret_cast<PrintPreviewUI*>(preview_tab->web_ui()); + ASSERT_TRUE(preview_ui != NULL); // Test with invalid |preview_ui_addr|. bool cancel = false; diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index eee2774..f631ce6 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1909,7 +1909,6 @@ 'browser/ui/webui/ntp/shown_sections_handler_unittest.cc', 'browser/ui/webui/options/chromeos/virtual_keyboard_manager_handler_unittest.cc', 'browser/ui/webui/options/language_options_handler_unittest.cc', - 'browser/ui/webui/print_preview_handler_unittest.cc', 'browser/ui/webui/print_preview_ui_unittest.cc', 'browser/ui/webui/sync_internals_ui_unittest.cc', 'browser/ui/webui/theme_source_unittest.cc', @@ -2078,7 +2077,6 @@ ['exclude', '^../content/browser/geolocation/wifi_data_provider_linux_unittest.cc'], # TODO(thestig) Enable PrintPreviewUI tests on CrOS when # print preview is enabled on CrOS. - ['exclude', '^browser/ui/webui/print_preview_handler_unittest.cc'], ['exclude', '^browser/ui/webui/print_preview_ui_unittest.cc'], ], }, { # else: chromeos == 0 diff --git a/chrome/test/base/testing_browser_process.cc b/chrome/test/base/testing_browser_process.cc index b672cf0..f86f6d5 100644 --- a/chrome/test/base/testing_browser_process.cc +++ b/chrome/test/base/testing_browser_process.cc @@ -11,7 +11,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prerender/prerender_tracker.h" #include "chrome/browser/printing/background_printing_manager.h" -#include "chrome/browser/printing/print_preview_tab_controller.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/browser/debugger/devtools_manager.h" #include "net/url_request/url_request_context_getter.h" @@ -199,9 +198,7 @@ printing::PrintJobManager* TestingBrowserProcess::print_job_manager() { printing::PrintPreviewTabController* TestingBrowserProcess::print_preview_tab_controller() { - if (!print_preview_tab_controller_.get()) - print_preview_tab_controller_ = new printing::PrintPreviewTabController(); - return print_preview_tab_controller_.get(); + return NULL; } printing::BackgroundPrintingManager* diff --git a/chrome/test/base/testing_browser_process.h b/chrome/test/base/testing_browser_process.h index 18b72e0..5659875 100644 --- a/chrome/test/base/testing_browser_process.h +++ b/chrome/test/base/testing_browser_process.h @@ -126,7 +126,7 @@ class TestingBrowserProcess : public BrowserProcess { void SetGoogleURLTracker(GoogleURLTracker* google_url_tracker); void SetProfileManager(ProfileManager* profile_manager); void SetIOThread(IOThread* io_thread); - void SetDevToolsManager(DevToolsManager* manager); + void SetDevToolsManager(DevToolsManager*); private: NotificationService notification_service_; @@ -141,8 +141,6 @@ class TestingBrowserProcess : public BrowserProcess { scoped_ptr<ProfileManager> profile_manager_; scoped_ptr<NotificationUIManager> notification_ui_manager_; scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_; - scoped_refptr<printing::PrintPreviewTabController> - print_preview_tab_controller_; scoped_ptr<prerender::PrerenderTracker> prerender_tracker_; IOThread* io_thread_; scoped_ptr<DevToolsManager> devtools_manager_; |