|
54 | 54 | #include "components/guest_view/browser/guest_view_manager_factory.h"
|
55 | 55 | #include "components/guest_view/browser/test_guest_view_manager.h"
|
56 | 56 | #include "content/public/browser/ax_event_notification_details.h"
|
| 57 | +#include "content/public/browser/browser_child_process_host_iterator.h" |
| 58 | +#include "content/public/browser/child_process_data.h" |
| 59 | +#include "content/public/common/process_type.h" |
57 | 60 | #include "content/public/browser/gpu_data_manager.h"
|
58 | 61 | #include "content/public/browser/interstitial_page.h"
|
59 | 62 | #include "content/public/browser/interstitial_page_delegate.h"
|
@@ -118,6 +121,7 @@ using task_manager::browsertest_util::MatchBackground;
|
118 | 121 | using task_manager::browsertest_util::MatchWebView;
|
119 | 122 | using task_manager::browsertest_util::WaitForTaskManagerRows;
|
120 | 123 | using ui::MenuModel;
|
| 124 | +using content::BrowserThread; |
121 | 125 |
|
122 | 126 | namespace {
|
123 | 127 | const char kEmptyResponsePath[] = "/close-socket";
|
@@ -862,11 +866,63 @@ class NWJSWebViewTest : public NWWebViewTestBase, public testing::WithParamInter
|
862 | 866 |
|
863 | 867 | INSTANTIATE_TEST_CASE_P(NWJSWebViewTests, NWJSWebViewTest, testing::Bool());
|
864 | 868 |
|
| 869 | +class NWAppTest : public extensions::PlatformAppBrowserTest { |
| 870 | +public: |
| 871 | + NWAppTest() {} |
| 872 | + ~NWAppTest() override {} |
| 873 | + void SetUpCommandLine(base::CommandLine* command_line) override { |
| 874 | + extensions::PlatformAppBrowserTest::SetUpCommandLine(command_line); |
| 875 | + PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir_); |
| 876 | + test_data_dir_ = test_data_dir_.Append(FILE_PATH_LITERAL("content")); |
| 877 | + test_data_dir_ = test_data_dir_.Append(FILE_PATH_LITERAL("nw")); |
| 878 | + test_data_dir_ = test_data_dir_.Append(FILE_PATH_LITERAL("test")); |
| 879 | + test_data_dir_ = test_data_dir_.Append(FILE_PATH_LITERAL("data")); |
| 880 | + } |
| 881 | + static void CountPluginProcesses(int* count, const base::Closure& quit_task) { |
| 882 | + for (content::BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
| 883 | + if (iter.GetData().process_type == content::PROCESS_TYPE_PPAPI_PLUGIN) |
| 884 | + (*count)++; |
| 885 | + } |
| 886 | + BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
| 887 | + } |
| 888 | + static void EnsureFlashProcessCount(int expected) { |
| 889 | + int actual = 0; |
| 890 | + scoped_refptr<content::MessageLoopRunner> runner = |
| 891 | + new content::MessageLoopRunner; |
| 892 | + BrowserThread::PostTask( |
| 893 | + BrowserThread::IO, |
| 894 | + FROM_HERE, |
| 895 | + base::Bind(&CountPluginProcesses, &actual, runner->QuitClosure())); |
| 896 | + runner->Run(); |
| 897 | + ASSERT_EQ(expected, actual); |
| 898 | + } |
| 899 | + |
| 900 | +}; |
865 | 901 |
|
866 | 902 | void NWTimeoutCallback(const std::string& timeout_message) {
|
867 | 903 | base::MessageLoop::current()->QuitWhenIdle();
|
868 | 904 | }
|
869 | 905 |
|
| 906 | +IN_PROC_BROWSER_TEST_F(NWAppTest, LocalFlash) { |
| 907 | + std::string contents; |
| 908 | + base::FilePath test_dir = test_data_dir_.Append(FILE_PATH_LITERAL("platform_apps")).Append(FILE_PATH_LITERAL("local_flash")); |
| 909 | + base::FilePath tpl_path = test_dir.Append(FILE_PATH_LITERAL("index.tpl")); |
| 910 | + base::FilePath swf_path = test_dir.Append(FILE_PATH_LITERAL("test.swf")); |
| 911 | + base::FilePath index_html = test_dir.Append(FILE_PATH_LITERAL("index.html")); |
| 912 | + ASSERT_TRUE(base::ReadFileToString(tpl_path, &contents)); |
| 913 | + GURL swf_url = net::FilePathToFileURL(swf_path); |
| 914 | + base::ReplaceSubstringsAfterOffset(&contents, 0, "<swf_path>", swf_url.spec()); |
| 915 | + EXPECT_GT(base::WriteFile(index_html, contents.c_str(), contents.size()), 0); |
| 916 | + |
| 917 | + LoadAndLaunchPlatformApp("local_flash", "Launched"); |
| 918 | + content::WebContents* web_contents = GetFirstAppWindowWebContents(); |
| 919 | + ASSERT_TRUE(web_contents); |
| 920 | + base::string16 expected_title(base::ASCIIToUTF16("Loaded")); |
| 921 | + content::TitleWatcher title_watcher(web_contents, expected_title); |
| 922 | + |
| 923 | + EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 924 | +} |
| 925 | + |
870 | 926 | IN_PROC_BROWSER_TEST_P(NWJSWebViewTest, LocalPDF) {
|
871 | 927 | std::string contents;
|
872 | 928 | base::FilePath test_dir = test_data_dir_.Append(FILE_PATH_LITERAL("platform_apps")).Append(FILE_PATH_LITERAL("local_pdf"));
|
|
0 commit comments