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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 10 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 static void LoadAndWaitInWindow(Shell* window, const GURL& url) { | 85 static void LoadAndWaitInWindow(Shell* window, const GURL& url) { |
86 string16 expected_title(ASCIIToUTF16("OK")); | 86 string16 expected_title(ASCIIToUTF16("OK")); |
87 TitleWatcher title_watcher(window->web_contents(), expected_title); | 87 TitleWatcher title_watcher(window->web_contents(), expected_title); |
88 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | 88 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); |
89 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); | 89 title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); |
90 NavigateToURL(window, url); | 90 NavigateToURL(window, url); |
91 string16 title = title_watcher.WaitAndGetTitle(); | 91 string16 title = title_watcher.WaitAndGetTitle(); |
92 if (title == ASCIIToUTF16("plugin_not_found")) { | 92 if (title == ASCIIToUTF16("plugin_not_found")) { |
93 const testing::TestInfo* const test_info = | 93 const testing::TestInfo* const test_info = |
94 testing::UnitTest::GetInstance()->current_test_info(); | 94 testing::UnitTest::GetInstance()->current_test_info(); |
95 LOG(INFO) << "PluginTest." << test_info->name() << | 95 VLOG(0) << "PluginTest." << test_info->name() |
96 " not running because plugin not installed."; | 96 << " not running because plugin not installed."; |
97 } else { | 97 } else { |
98 EXPECT_EQ(expected_title, title); | 98 EXPECT_EQ(expected_title, title); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 void LoadAndWait(const GURL& url) { | 102 void LoadAndWait(const GURL& url) { |
103 LoadAndWaitInWindow(shell(), url); | 103 LoadAndWaitInWindow(shell(), url); |
104 } | 104 } |
105 | 105 |
106 GURL GetURL(const char* filename) { | 106 GURL GetURL(const char* filename) { |
107 return GetTestUrl("npapi", filename); | 107 return GetTestUrl("npapi", filename); |
108 } | 108 } |
109 | 109 |
110 void NavigateAway() { | 110 void NavigateAway() { |
111 GURL url = GetTestUrl("", "simple_page.html"); | 111 GURL url = GetTestUrl("", "simple_page.html"); |
112 LoadAndWait(url); | 112 LoadAndWait(url); |
113 } | 113 } |
114 | 114 |
115 void TestPlugin(const char* filename) { | 115 void TestPlugin(const char* filename) { |
116 base::FilePath path = GetTestFilePath("plugin", filename); | 116 base::FilePath path = GetTestFilePath("plugin", filename); |
117 if (!base::PathExists(path)) { | 117 if (!base::PathExists(path)) { |
118 const testing::TestInfo* const test_info = | 118 const testing::TestInfo* const test_info = |
119 testing::UnitTest::GetInstance()->current_test_info(); | 119 testing::UnitTest::GetInstance()->current_test_info(); |
120 LOG(INFO) << "PluginTest." << test_info->name() << | 120 VLOG(0) << "PluginTest." << test_info->name() |
121 " not running because test data wasn't found."; | 121 << " not running because test data wasn't found."; |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 GURL url = GetTestUrl("plugin", filename); | 125 GURL url = GetTestUrl("plugin", filename); |
126 LoadAndWait(url); | 126 LoadAndWait(url); |
127 } | 127 } |
128 }; | 128 }; |
129 | 129 |
130 // Make sure that navigating away from a plugin referenced by JS doesn't | 130 // Make sure that navigating away from a plugin referenced by JS doesn't |
131 // crash. | 131 // crash. |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 ResourceDispatcherHostDelegate* old_delegate = | 548 ResourceDispatcherHostDelegate* old_delegate = |
549 ResourceDispatcherHostImpl::Get()->delegate(); | 549 ResourceDispatcherHostImpl::Get()->delegate(); |
550 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); | 550 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); |
551 LoadAndWait(url); | 551 LoadAndWait(url); |
552 test_delegate.WaitForPluginRequest(); | 552 test_delegate.WaitForPluginRequest(); |
553 ASSERT_TRUE(test_delegate.found_cookie()); | 553 ASSERT_TRUE(test_delegate.found_cookie()); |
554 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); | 554 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); |
555 } | 555 } |
556 | 556 |
557 } // namespace content | 557 } // namespace content |
OLD | NEW |