OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "base/string16.h" | 6 #include "base/string16.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | |
8 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
9 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/automation/browser_proxy.h" | 11 #include "chrome/test/automation/browser_proxy.h" |
11 #include "chrome/test/automation/tab_proxy.h" | 12 #include "chrome/test/automation/tab_proxy.h" |
12 #include "chrome/test/ui/ui_test.h" | 13 #include "chrome/test/ui/ui_test.h" |
13 | 14 |
14 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
(...skipping 21 matching lines...) Expand all Loading... | |
39 ASSERT_TRUE(browser.get()); | 40 ASSERT_TRUE(browser.get()); |
40 | 41 |
41 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); | 42 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); |
42 ASSERT_TRUE(tab.get()); | 43 ASSERT_TRUE(tab.get()); |
43 | 44 |
44 // Go to the print preview tab via URL. | 45 // Go to the print preview tab via URL. |
45 NavigateToURL(GURL(chrome::kChromeUIPrintURL)); | 46 NavigateToURL(GURL(chrome::kChromeUIPrintURL)); |
46 AssertIsPrintPage(tab); | 47 AssertIsPrintPage(tab); |
47 } | 48 } |
48 | 49 |
50 TEST_F(PrintPreviewUITest, PrintCommandDisabled) { | |
51 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
52 ASSERT_TRUE(browser.get()); | |
53 | |
54 // Go to the about:blank page. | |
55 NavigateToURL(GURL(chrome::kAboutBlankURL)); | |
56 | |
57 // Make sure there is 1 tab and print is enabled. Create print preview tab. | |
58 int tab_count; | |
59 ASSERT_TRUE(browser->GetTabCount(&tab_count)); | |
60 ASSERT_EQ(1, tab_count); | |
61 bool enabled; | |
62 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_PRINT, &enabled)); | |
63 ASSERT_TRUE(enabled); | |
64 ASSERT_TRUE(browser->RunCommandAsync(IDC_PRINT)); | |
65 | |
66 // Make sure there are 2 tabs and print is disabled. | |
67 WaitUntilTabCount(2); | |
68 // Sometimes the title comes up blank without this sleep. | |
69 PlatformThread::Sleep(1000); | |
Paweł Hajdan Jr.
2010/12/02 09:36:36
This is a no-go. Do you need to wait for some even
Lei Zhang
2010/12/02 18:06:12
I'm already waiting with WaitUntilTabCount() - I s
Paweł Hajdan Jr.
2010/12/02 18:43:32
I think the main problem is that the test doesn't
| |
70 scoped_refptr<TabProxy> tab = browser->GetActiveTab(); | |
71 ASSERT_TRUE(tab.get()); | |
72 AssertIsPrintPage(tab); | |
73 ASSERT_TRUE(browser->IsMenuCommandEnabled(IDC_PRINT, &enabled)); | |
74 ASSERT_FALSE(enabled); | |
75 } | |
76 | |
49 } // namespace | 77 } // namespace |
OLD | NEW |