diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 03:07:13 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-06 03:07:13 +0000 |
commit | 91450c1a0024a183852e97b857e04dbf7ccb5dc6 (patch) | |
tree | 7553658c1a0779551c102b78aec18e5071cb038e /ppapi | |
parent | 7a4c99fe58e7321b76e296551e9b4a377766b965 (diff) | |
download | chromium_src-91450c1a0024a183852e97b857e04dbf7ccb5dc6.zip chromium_src-91450c1a0024a183852e97b857e04dbf7ccb5dc6.tar.gz chromium_src-91450c1a0024a183852e97b857e04dbf7ccb5dc6.tar.bz2 |
Fix PPAPI TestCase so individual tests can be run more than once.
When tests are run multiple times (e.g. to test callback types), only
the first invocation runs.
BUG=
Review URL: https://chromiumcodereview.appspot.com/21833005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215776 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/tests/test_case.cc | 20 | ||||
-rw-r--r-- | ppapi/tests/test_case.h | 23 | ||||
-rw-r--r-- | ppapi/tests/test_file_io.cc | 4 |
3 files changed, 27 insertions, 20 deletions
diff --git a/ppapi/tests/test_case.cc b/ppapi/tests/test_case.cc index 733faad..6f61fc5 100644 --- a/ppapi/tests/test_case.cc +++ b/ppapi/tests/test_case.cc @@ -81,7 +81,7 @@ TestCase::TestCase(TestingInstance* instance) : instance_(instance), testing_interface_(NULL), callback_type_(PP_REQUIRED), - have_populated_remaining_tests_(false) { + have_populated_filter_tests_(false) { // Get the testing_interface_ if it is available, so that we can do Resource // and Var checks on shutdown (see CheckResourcesAndVars). If it is not // available, testing_interface_ will be NULL. Some tests do not require it. @@ -181,21 +181,21 @@ bool TestCase::ShouldRunTest(const std::string& test_name, if (ShouldRunAllTests(filter)) return true; - // Lazily initialize our "remaining_tests_" map. - if (!have_populated_remaining_tests_) { - ParseTestFilter(filter, &remaining_tests_); - have_populated_remaining_tests_ = true; + // Lazily initialize our "filter_tests_" map. + if (!have_populated_filter_tests_) { + ParseTestFilter(filter, &filter_tests_); + remaining_tests_ = filter_tests_; + have_populated_filter_tests_ = true; } - std::map<std::string, bool>::iterator iter = remaining_tests_.find(test_name); - if (iter == remaining_tests_.end()) { + std::map<std::string, bool>::iterator iter = filter_tests_.find(test_name); + if (iter == filter_tests_.end()) { // The test name wasn't listed in the filter. Don't run it, but store it // so TestingInstance::ExecuteTests can report an error later. skipped_tests_.insert(test_name); return false; } - bool should_run_test = iter->second; - remaining_tests_.erase(iter); - return should_run_test; + remaining_tests_.erase(test_name); + return iter->second; } PP_TimeTicks TestCase::NowInTimeTicks() { diff --git a/ppapi/tests/test_case.h b/ppapi/tests/test_case.h index 4491c76..9a3c31f 100644 --- a/ppapi/tests/test_case.h +++ b/ppapi/tests/test_case.h @@ -224,18 +224,21 @@ class TestCase { // Var ids that should be ignored when checking for leaks on shutdown. std::set<int64_t> ignored_leaked_vars_; - // The tests that were found in test_filter but have not yet been run. The - // bool indicates whether the test should be run (i.e., it will be false if - // the test name was prefixed in the test_filter string). + // The tests that were found in test_filter. The bool indicates whether the + // test should be run (i.e., it will be false if the test name was prefixed in + // the test_filter string). // - // This is initialized lazily the first time that ShouldRunTest is called by - // RunTests. When RunTests is finished, this should be empty. Any remaining - // tests are tests that were listed in the test_filter but didn't match - // any calls to ShouldRunTest, meaning it was probably a typo. TestingInstance - // should log this and consider it a failure. + // This is initialized lazily the first time that ShouldRunTest is called. + std::map<std::string, bool> filter_tests_; + // Flag indicating whether we have populated filter_tests_ yet. + bool have_populated_filter_tests_; + // This is initialized with the contents of filter_tests_. As each test is + // run, it is removed from remaining_tests_. When RunTests is finished, + // remaining_tests_ should be empty. Any remaining tests are tests that were + // listed in the test_filter but didn't match any calls to ShouldRunTest, + // meaning it was probably a typo. TestingInstance should log this and + // consider it a failure. std::map<std::string, bool> remaining_tests_; - // Flag indicating whether we have populated remaining_tests_ yet. - bool have_populated_remaining_tests_; // If ShouldRunTest is called but the given test name doesn't match anything // in the test_filter, the test name will be added here. This allows diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc index 2d0da5c..ed2183b 100644 --- a/ppapi/tests/test_file_io.cc +++ b/ppapi/tests/test_file_io.cc @@ -1138,6 +1138,10 @@ std::string TestFileIO::TestRequestOSFileHandleWithOpenExclusive() { callback.WaitForResult(file_system.Open(1024, callback.GetCallback())); ASSERT_EQ(PP_OK, callback.result()); + // Open with PP_FILEOPENFLAG_CREATE and PP_FILEOPENFLAG_EXCLUSIVE will fail + // if the file already exists. Delete it here to make sure it does not. + callback.WaitForResult(file_ref.Delete(callback.GetCallback())); + pp::FileIO_Private file_io(instance_); callback.WaitForResult(file_io.Open(file_ref, PP_FILEOPENFLAG_CREATE | |