OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
10 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 const extensions::Extension* LoadTestExtension() { | 21 const extensions::Extension* LoadTestExtension() { |
22 const extensions::Extension* extension = LoadExtension( | 22 const extensions::Extension* extension = LoadExtension( |
23 test_data_dir_.AppendASCII("mime_handler_view")); | 23 test_data_dir_.AppendASCII("mime_handler_view")); |
24 if (!extension) | 24 if (!extension) |
25 return nullptr; | 25 return nullptr; |
26 | 26 |
27 CHECK_EQ(std::string(kExtensionId), extension->id()); | 27 CHECK_EQ(std::string(kExtensionId), extension->id()); |
28 | 28 |
29 return extension; | 29 return extension; |
30 } | 30 } |
| 31 |
| 32 void RunTest(const std::string& path) { |
| 33 const extensions::Extension* extension = LoadTestExtension(); |
| 34 ASSERT_TRUE(extension); |
| 35 |
| 36 extensions::ResultCatcher catcher; |
| 37 |
| 38 GURL extension_url("chrome-extension://" + std::string(kExtensionId) + "/" + |
| 39 path); |
| 40 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 41 |
| 42 if (!catcher.GetNextResult()) |
| 43 FAIL() << catcher.message(); |
| 44 } |
31 }; | 45 }; |
32 | 46 |
33 // Not working on Windows because of crbug.com/443466. | 47 // Not working on Windows because of crbug.com/443466. |
34 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
35 #define MAYBE_PostMessage DISABLED_PostMessage | 49 #define MAYBE_PostMessage DISABLED_PostMessage |
36 #else | 50 #else |
37 #define MAYBE_PostMessage PostMessage | 51 #define MAYBE_PostMessage PostMessage |
38 #endif | 52 #endif |
39 | 53 |
40 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, MAYBE_PostMessage) { | 54 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, MAYBE_PostMessage) { |
41 const extensions::Extension* extension = LoadTestExtension(); | 55 RunTest("test_postmessage.html"); |
42 ASSERT_TRUE(extension); | 56 } |
43 | 57 |
44 extensions::ResultCatcher catcher; | 58 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Basic) { |
| 59 RunTest("testBasic.csv"); |
| 60 } |
45 | 61 |
46 GURL extension_url("chrome-extension://" + | 62 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Embedded) { |
47 std::string(kExtensionId) + | 63 RunTest("test_embedded.html"); |
48 "/test_postmessage.html"); | 64 } |
49 ui_test_utils::NavigateToURL(browser(), extension_url); | |
50 | 65 |
51 if (!catcher.GetNextResult()) | 66 IN_PROC_BROWSER_TEST_F(MimeHandlerViewTest, Abort) { |
52 FAIL() << catcher.message(); | 67 RunTest("testAbort.csv"); |
53 } | 68 } |
OLD | NEW |