OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "base/utf_string_conversions.h" |
10 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
12 #include "chrome/test/ui_test_utils.h" | 13 #include "chrome/test/ui_test_utils.h" |
13 #include "chrome/test/automation/tab_proxy.h" | 14 #include "chrome/test/automation/tab_proxy.h" |
14 #include "chrome/test/ui/npapi_test_helper.h" | 15 #include "chrome/test/ui/npapi_test_helper.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
17 | 18 |
18 using npapi_test::kTestCompleteCookie; | 19 using npapi_test::kTestCompleteCookie; |
19 using npapi_test::kTestCompleteSuccess; | 20 using npapi_test::kTestCompleteSuccess; |
20 | 21 |
21 static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("npapi"); | 22 static const FilePath::CharType* kTestDir = FILE_PATH_LITERAL("npapi"); |
22 | 23 |
23 class LayoutPluginTester : public NPAPITesterBase { | 24 class LayoutPluginTester : public NPAPITesterBase { |
24 protected: | 25 protected: |
25 LayoutPluginTester() : NPAPITesterBase() {} | 26 LayoutPluginTester() : NPAPITesterBase() {} |
26 }; | 27 }; |
27 | 28 |
28 // Make sure that navigating away from a plugin referenced by JS doesn't | 29 // Make sure that navigating away from a plugin referenced by JS doesn't |
29 // crash. | 30 // crash. |
30 TEST_F(LayoutPluginTester, UnloadNoCrash) { | 31 TEST_F(LayoutPluginTester, UnloadNoCrash) { |
31 FilePath path; | 32 FilePath path; |
32 PathService::Get(chrome::DIR_TEST_DATA, &path); | 33 PathService::Get(chrome::DIR_TEST_DATA, &path); |
33 path = path.AppendASCII("npapi").AppendASCII("layout_test_plugin.html"); | 34 path = path.AppendASCII("npapi").AppendASCII("layout_test_plugin.html"); |
34 NavigateToURL(net::FilePathToFileURL(path)); | 35 NavigateToURL(net::FilePathToFileURL(path)); |
35 | 36 |
36 std::wstring title; | 37 string16 title; |
37 scoped_refptr<TabProxy> tab = GetActiveTab(); | 38 scoped_refptr<TabProxy> tab = GetActiveTab(); |
38 ASSERT_TRUE(tab); | 39 ASSERT_TRUE(tab); |
39 EXPECT_TRUE(tab->GetTabTitle(&title)); | 40 EXPECT_TRUE(tab->GetTabTitle(&title)); |
40 EXPECT_EQ(L"Layout Test Plugin Test", title); | 41 EXPECT_EQ(ASCIIToUTF16("Layout Test Plugin Test"), title); |
41 | 42 |
42 ASSERT_TRUE(tab->GoBack()); | 43 ASSERT_TRUE(tab->GoBack()); |
43 EXPECT_TRUE(tab->GetTabTitle(&title)); | 44 EXPECT_TRUE(tab->GetTabTitle(&title)); |
44 EXPECT_EQ(L"", title); | 45 EXPECT_EQ(string16(), title); |
45 } | 46 } |
46 | 47 |
47 // Tests if a plugin executing a self deleting script using NPN_GetURL | 48 // Tests if a plugin executing a self deleting script using NPN_GetURL |
48 // works without crashing or hanging | 49 // works without crashing or hanging |
49 // Flaky: http://crbug.com/59327 | 50 // Flaky: http://crbug.com/59327 |
50 TEST_F(LayoutPluginTester, FLAKY_SelfDeletePluginGetUrl) { | 51 TEST_F(LayoutPluginTester, FLAKY_SelfDeletePluginGetUrl) { |
51 const FilePath test_case(FILE_PATH_LITERAL("self_delete_plugin_geturl.html")); | 52 const FilePath test_case(FILE_PATH_LITERAL("self_delete_plugin_geturl.html")); |
52 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); | 53 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); |
53 ASSERT_NO_FATAL_FAILURE(NavigateToURL(url)); | 54 ASSERT_NO_FATAL_FAILURE(NavigateToURL(url)); |
54 WaitForFinish("self_delete_plugin_geturl", "1", url, | 55 WaitForFinish("self_delete_plugin_geturl", "1", url, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // the more interesting case is out of process, where we must route | 92 // the more interesting case is out of process, where we must route |
92 // the exception to the correct renderer. | 93 // the exception to the correct renderer. |
93 TEST_F(LayoutPluginTester, NPObjectSetException) { | 94 TEST_F(LayoutPluginTester, NPObjectSetException) { |
94 const FilePath test_case(FILE_PATH_LITERAL("npobject_set_exception.html")); | 95 const FilePath test_case(FILE_PATH_LITERAL("npobject_set_exception.html")); |
95 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); | 96 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); |
96 ASSERT_NO_FATAL_FAILURE(NavigateToURL(url)); | 97 ASSERT_NO_FATAL_FAILURE(NavigateToURL(url)); |
97 WaitForFinish("npobject_set_exception", "1", url, | 98 WaitForFinish("npobject_set_exception", "1", url, |
98 kTestCompleteCookie, kTestCompleteSuccess, | 99 kTestCompleteCookie, kTestCompleteSuccess, |
99 TestTimeouts::action_max_timeout_ms()); | 100 TestTimeouts::action_max_timeout_ms()); |
100 } | 101 } |
OLD | NEW |