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 "base/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_commands.h" |
8 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
9 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
11 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
13 #include "net/test/test_server.h" | 14 #include "net/test/test_server.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 const char kTestHtml[] = "files/viewsource/test.html"; | 17 const char kTestHtml[] = "files/viewsource/test.html"; |
17 } | 18 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 59 } |
59 | 60 |
60 // Make sure that when looking at the actual page, we can select "View Source" | 61 // Make sure that when looking at the actual page, we can select "View Source" |
61 // from the menu. | 62 // from the menu. |
62 IN_PROC_BROWSER_TEST_F(ViewSourceTest, ViewSourceInMenuEnabledOnANormalPage) { | 63 IN_PROC_BROWSER_TEST_F(ViewSourceTest, ViewSourceInMenuEnabledOnANormalPage) { |
63 ASSERT_TRUE(test_server()->Start()); | 64 ASSERT_TRUE(test_server()->Start()); |
64 | 65 |
65 GURL url(test_server()->GetURL(kTestHtml)); | 66 GURL url(test_server()->GetURL(kTestHtml)); |
66 ui_test_utils::NavigateToURL(browser(), url); | 67 ui_test_utils::NavigateToURL(browser(), url); |
67 | 68 |
68 EXPECT_TRUE(browser()->command_updater()->IsCommandEnabled(IDC_VIEW_SOURCE)); | 69 EXPECT_TRUE(chrome::CanViewSource(browser())); |
69 } | 70 } |
70 | 71 |
71 // Make sure that when looking at the page source, we can't select "View Source" | 72 // Make sure that when looking at the page source, we can't select "View Source" |
72 // from the menu. | 73 // from the menu. |
73 // | 74 // |
74 // Occasionally crashes on all platforms, see http://crbug.com/69249 | 75 // Occasionally crashes on all platforms, see http://crbug.com/69249 |
75 IN_PROC_BROWSER_TEST_F(ViewSourceTest, | 76 IN_PROC_BROWSER_TEST_F(ViewSourceTest, |
76 ViewSourceInMenuDisabledWhileViewingSource) { | 77 ViewSourceInMenuDisabledWhileViewingSource) { |
77 ASSERT_TRUE(test_server()->Start()); | 78 ASSERT_TRUE(test_server()->Start()); |
78 | 79 |
79 GURL url_viewsource(chrome::kViewSourceScheme + std::string(":") + | 80 GURL url_viewsource(chrome::kViewSourceScheme + std::string(":") + |
80 test_server()->GetURL(kTestHtml).spec()); | 81 test_server()->GetURL(kTestHtml).spec()); |
81 ui_test_utils::NavigateToURL(browser(), url_viewsource); | 82 ui_test_utils::NavigateToURL(browser(), url_viewsource); |
82 | 83 |
83 EXPECT_FALSE(browser()->command_updater()->IsCommandEnabled(IDC_VIEW_SOURCE)); | 84 EXPECT_FALSE(chrome::CanViewSource(browser())); |
84 } | 85 } |
OLD | NEW |