| Index: chrome/browser/dom_ui/print_preview_ui_uitest.cc
 | 
| ===================================================================
 | 
| --- chrome/browser/dom_ui/print_preview_ui_uitest.cc	(revision 68080)
 | 
| +++ chrome/browser/dom_ui/print_preview_ui_uitest.cc	(working copy)
 | 
| @@ -5,6 +5,7 @@
 | 
|  #include "app/l10n_util.h"
 | 
|  #include "base/string16.h"
 | 
|  #include "base/utf_string_conversions.h"
 | 
| +#include "chrome/app/chrome_command_ids.h"
 | 
|  #include "chrome/common/chrome_switches.h"
 | 
|  #include "chrome/common/url_constants.h"
 | 
|  #include "chrome/test/automation/browser_proxy.h"
 | 
| @@ -24,6 +25,14 @@
 | 
|    }
 | 
|  
 | 
|    void AssertIsPrintPage(TabProxy* tab) {
 | 
| +    // Wait for '#mainview' to become visible to make sure the document is
 | 
| +    // mostly loaded. Otherwise GetTabTitle() below is flaky.
 | 
| +    scoped_refptr<DOMElementProxy> dom(tab->GetDOMDocument());
 | 
| +    ASSERT_TRUE(dom.get());
 | 
| +    scoped_refptr<DOMElementProxy> mainview = dom->WaitFor1VisibleElement(
 | 
| +        DOMElementProxy::By::Selectors("#mainview"));
 | 
| +    ASSERT_TRUE(mainview.get());
 | 
| +
 | 
|      std::wstring title;
 | 
|      ASSERT_TRUE(tab->GetTabTitle(&title));
 | 
|      string16 expected_title =
 | 
| @@ -46,4 +55,29 @@
 | 
|    AssertIsPrintPage(tab);
 | 
|  }
 | 
|  
 | 
| +TEST_F(PrintPreviewUITest, PrintCommandDisabled) {
 | 
| +  scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
 | 
| +  ASSERT_TRUE(browser.get());
 | 
| +
 | 
| +  // Go to the about:blank page.
 | 
| +  NavigateToURL(GURL(chrome::kAboutBlankURL));
 | 
| +
 | 
| +  // Make sure there is 1 tab and print is enabled. Create print preview tab.
 | 
| +  int tab_count;
 | 
| +  ASSERT_TRUE(browser->GetTabCount(&tab_count));
 | 
| +  ASSERT_EQ(1, tab_count);
 | 
| +  bool enabled;
 | 
| +  ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_PRINT, &enabled));
 | 
| +  ASSERT_TRUE(enabled);
 | 
| +  ASSERT_TRUE(browser->RunCommandAsync(IDC_PRINT));
 | 
| +
 | 
| +  // Make sure there are 2 tabs and print is disabled.
 | 
| +  WaitUntilTabCount(2);
 | 
| +  scoped_refptr<TabProxy> tab = browser->GetActiveTab();
 | 
| +  ASSERT_TRUE(tab.get());
 | 
| +  AssertIsPrintPage(tab);
 | 
| +  ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_PRINT, &enabled));
 | 
| +  ASSERT_FALSE(enabled);
 | 
| +}
 | 
| +
 | 
|  }  // namespace
 | 
| 
 |