| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/string16.h" | |
| 6 #include "base/utf_string_conversions.h" | |
| 7 #include "chrome/app/chrome_command_ids.h" | |
| 8 #include "chrome/common/chrome_switches.h" | |
| 9 #include "chrome/common/url_constants.h" | |
| 10 #include "chrome/test/automation/automation_proxy.h" | |
| 11 #include "chrome/test/automation/browser_proxy.h" | |
| 12 #include "chrome/test/automation/tab_proxy.h" | |
| 13 #include "chrome/test/ui/ui_test.h" | |
| 14 #include "grit/generated_resources.h" | |
| 15 #include "ui/base/l10n/l10n_util.h" | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 class PrintPreviewUITest : public UITest { | |
| 20 public: | |
| 21 PrintPreviewUITest() { | |
| 22 dom_automation_enabled_ = true; | |
| 23 launch_arguments_.AppendSwitch(switches::kEnablePrintPreview); | |
| 24 } | |
| 25 }; | |
| 26 | |
| 27 TEST_F(PrintPreviewUITest, PrintCommands) { | |
| 28 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
| 29 ASSERT_TRUE(browser.get()); | |
| 30 | |
| 31 // Go to the about:blank page. | |
| 32 NavigateToURL(GURL(chrome::kAboutBlankURL)); | |
| 33 | |
| 34 // Make sure there is 1 tab and print is enabled. | |
| 35 int tab_count; | |
| 36 ASSERT_TRUE(browser->GetTabCount(&tab_count)); | |
| 37 ASSERT_EQ(1, tab_count); | |
| 38 | |
| 39 bool enabled = false; | |
| 40 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_PRINT, &enabled)); | |
| 41 ASSERT_TRUE(enabled); | |
| 42 | |
| 43 // Make sure advanced print command (Ctrl+Shift+p) is enabled. | |
| 44 enabled = false; | |
| 45 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_ADVANCED_PRINT, &enabled)); | |
| 46 ASSERT_TRUE(enabled); | |
| 47 | |
| 48 // Create print preview tab. | |
| 49 ASSERT_TRUE(browser->RunCommand(IDC_PRINT)); | |
| 50 | |
| 51 // Make sure print is disabled. | |
| 52 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_PRINT, &enabled)); | |
| 53 ASSERT_FALSE(enabled); | |
| 54 | |
| 55 // Make sure advanced print command (Ctrl+Shift+p) is enabled. | |
| 56 enabled = false; | |
| 57 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_ADVANCED_PRINT, &enabled)); | |
| 58 ASSERT_TRUE(enabled); | |
| 59 | |
| 60 ASSERT_TRUE(browser->RunCommand(IDC_RELOAD)); | |
| 61 | |
| 62 enabled = false; | |
| 63 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_PRINT, &enabled)); | |
| 64 ASSERT_TRUE(enabled); | |
| 65 | |
| 66 // Make sure advanced print command (Ctrl+Shift+p) is enabled. | |
| 67 enabled = false; | |
| 68 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_ADVANCED_PRINT, &enabled)); | |
| 69 ASSERT_TRUE(enabled); | |
| 70 } | |
| 71 | |
| 72 } // namespace | |
| OLD | NEW |