| OLD | NEW |
| 1 // Copyright 2008, Google Inc. | 1 // Copyright 2008, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 7 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 8 // Use of this source code is governed by a BSD-style license that can be | 8 // Use of this source code is governed by a BSD-style license that can be |
| 9 // found in the LICENSE file. | 9 // found in the LICENSE file. |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 const char kTestCompleteSuccess[] = "OK"; | 30 const char kTestCompleteSuccess[] = "OK"; |
| 31 } // namespace npapi_test. | 31 } // namespace npapi_test. |
| 32 | 32 |
| 33 NPAPITesterBase::NPAPITesterBase(const std::string& test_plugin_name) | 33 NPAPITesterBase::NPAPITesterBase(const std::string& test_plugin_name) |
| 34 : test_plugin_name_(test_plugin_name) { | 34 : test_plugin_name_(test_plugin_name) { |
| 35 } | 35 } |
| 36 | 36 |
| 37 void NPAPITesterBase::SetUp() { | 37 void NPAPITesterBase::SetUp() { |
| 38 // We need to copy our test-plugin into the plugins directory so that | 38 // We need to copy our test-plugin into the plugins directory so that |
| 39 // the browser can load it. | 39 // the browser can load it. |
| 40 // TODO(tc): We should copy the plugins as a build step, not during |
| 41 // the tests. Then we don't have to clean up after the copy in the test. |
| 40 FilePath plugins_directory = GetPluginsDirectory(); | 42 FilePath plugins_directory = GetPluginsDirectory(); |
| 41 FilePath plugin_src = browser_directory_.AppendASCII(test_plugin_name_); | 43 FilePath plugin_src = browser_directory_.AppendASCII(test_plugin_name_); |
| 42 ASSERT_TRUE(file_util::PathExists(plugin_src)); | 44 ASSERT_TRUE(file_util::PathExists(plugin_src)); |
| 43 test_plugin_path_ = plugins_directory.AppendASCII(test_plugin_name_); | 45 test_plugin_path_ = plugins_directory.AppendASCII(test_plugin_name_); |
| 44 | 46 |
| 45 file_util::CreateDirectory(plugins_directory); | 47 file_util::CreateDirectory(plugins_directory); |
| 46 ASSERT_TRUE(file_util::CopyDirectory(plugin_src, test_plugin_path_, true)) | 48 ASSERT_TRUE(file_util::CopyDirectory(plugin_src, test_plugin_path_, true)) |
| 47 << "Copy failed from " << plugin_src.value() | 49 << "Copy failed from " << plugin_src.value() |
| 48 << " to " << test_plugin_path_.value(); | 50 << " to " << test_plugin_path_.value(); |
| 49 #if defined(OS_MACOSX) | 51 #if defined(OS_MACOSX) |
| 50 // The plugins directory isn't read by default on the Mac, so it needs to be | 52 // The plugins directory isn't read by default on the Mac, so it needs to be |
| 51 // explicitly registered. | 53 // explicitly registered. |
| 52 launch_arguments_.AppendSwitchPath(switches::kExtraPluginDir, | 54 launch_arguments_.AppendSwitchPath(switches::kExtraPluginDir, |
| 53 plugins_directory); | 55 plugins_directory); |
| 54 #endif | 56 #endif |
| 55 | 57 |
| 56 UITest::SetUp(); | 58 UITest::SetUp(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 void NPAPITesterBase::TearDown() { | 61 void NPAPITesterBase::TearDown() { |
| 60 // Tear down the UI test first so that the browser stops using the plugin | 62 // Tear down the UI test first so that the browser stops using the plugin |
| 61 // files. | 63 // files. |
| 62 UITest::TearDown(); | 64 UITest::TearDown(); |
| 63 EXPECT_TRUE(file_util::DieFileDie(test_plugin_path_, true)); | |
| 64 } | 65 } |
| 65 | 66 |
| 66 FilePath NPAPITesterBase::GetPluginsDirectory() { | 67 FilePath NPAPITesterBase::GetPluginsDirectory() { |
| 67 FilePath plugins_directory = browser_directory_.AppendASCII("plugins"); | 68 FilePath plugins_directory = browser_directory_.AppendASCII("plugins"); |
| 68 return plugins_directory; | 69 return plugins_directory; |
| 69 } | 70 } |
| 70 | 71 |
| 71 NPAPITester::NPAPITester() : NPAPITesterBase(kNpapiTestPluginName) { | 72 NPAPITester::NPAPITester() : NPAPITesterBase(kNpapiTestPluginName) { |
| 72 } | 73 } |
| 73 | 74 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 ASSERT_TRUE(file_util::CopyDirectory(layout_src, layout_plugin_path_, true)); | 85 ASSERT_TRUE(file_util::CopyDirectory(layout_src, layout_plugin_path_, true)); |
| 85 #endif | 86 #endif |
| 86 | 87 |
| 87 NPAPITesterBase::SetUp(); | 88 NPAPITesterBase::SetUp(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 void NPAPITester::TearDown() { | 91 void NPAPITester::TearDown() { |
| 91 // Tear down the base class first so that the browser stops using the plugin | 92 // Tear down the base class first so that the browser stops using the plugin |
| 92 // files. | 93 // files. |
| 93 NPAPITesterBase::TearDown(); | 94 NPAPITesterBase::TearDown(); |
| 94 #if defined(OS_MACOSX) | |
| 95 EXPECT_TRUE(file_util::DieFileDie(layout_plugin_path_, true)); | |
| 96 #endif // OS_MACOSX | |
| 97 } | 95 } |
| 98 | 96 |
| 99 // NPAPIVisiblePluginTester members. | 97 // NPAPIVisiblePluginTester members. |
| 100 void NPAPIVisiblePluginTester::SetUp() { | 98 void NPAPIVisiblePluginTester::SetUp() { |
| 101 show_window_ = true; | 99 show_window_ = true; |
| 102 NPAPITester::SetUp(); | 100 NPAPITester::SetUp(); |
| 103 } | 101 } |
| 104 | 102 |
| 105 // NPAPIIncognitoTester members. | 103 // NPAPIIncognitoTester members. |
| 106 void NPAPIIncognitoTester::SetUp() { | 104 void NPAPIIncognitoTester::SetUp() { |
| 107 launch_arguments_.AppendSwitch(switches::kIncognito); | 105 launch_arguments_.AppendSwitch(switches::kIncognito); |
| 108 NPAPITester::SetUp(); | 106 NPAPITester::SetUp(); |
| 109 } | 107 } |
| OLD | NEW |