OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ppapi/tests/test_case.h" | 5 #include "ppapi/tests/test_case.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "ppapi/tests/test_utils.h" | 9 #include "ppapi/tests/test_utils.h" |
10 #include "ppapi/tests/testing_instance.h" | 10 #include "ppapi/tests/testing_instance.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 100 } |
101 | 101 |
102 return true; | 102 return true; |
103 } | 103 } |
104 | 104 |
105 bool TestCase::MatchesFilter(const std::string& test_name, | 105 bool TestCase::MatchesFilter(const std::string& test_name, |
106 const std::string& filter) { | 106 const std::string& filter) { |
107 return filter.empty() || (test_name == filter); | 107 return filter.empty() || (test_name == filter); |
108 } | 108 } |
109 | 109 |
110 std::string TestCase::CheckResourcesAndVars() { | 110 std::string TestCase::CheckResourcesAndVars(std::string errors) { |
111 std::string errors; | 111 if (!errors.empty()) |
| 112 return errors; |
| 113 |
112 if (testing_interface_) { | 114 if (testing_interface_) { |
113 // TODO(dmichael): Fix tests that leak resources and enable the following: | 115 // TODO(dmichael): Fix tests that leak resources and enable the following: |
114 /* | 116 /* |
115 uint32_t leaked_resources = | 117 uint32_t leaked_resources = |
116 testing_interface_->GetLiveObjectsForInstance(instance_->pp_instance()); | 118 testing_interface_->GetLiveObjectsForInstance(instance_->pp_instance()); |
117 if (leaked_resources) { | 119 if (leaked_resources) { |
118 std::ostringstream output; | 120 std::ostringstream output; |
119 output << "FAILED: Test leaked " << leaked_resources << " resources.\n"; | 121 output << "FAILED: Test leaked " << leaked_resources << " resources.\n"; |
120 errors += output.str(); | 122 errors += output.str(); |
121 } | 123 } |
(...skipping 14 matching lines...) Expand all Loading... |
136 } | 138 } |
137 for (int i = 0; i < std::min(found_vars, kVarsToPrint); ++i) { | 139 for (int i = 0; i < std::min(found_vars, kVarsToPrint); ++i) { |
138 pp::Var leaked_var(pp::PASS_REF, vars[i]); | 140 pp::Var leaked_var(pp::PASS_REF, vars[i]); |
139 if (ignored_leaked_vars_.count(leaked_var.pp_var().value.as_id) == 0) | 141 if (ignored_leaked_vars_.count(leaked_var.pp_var().value.as_id) == 0) |
140 errors += leaked_var.DebugString() + "<p>"; | 142 errors += leaked_var.DebugString() + "<p>"; |
141 } | 143 } |
142 } | 144 } |
143 return errors; | 145 return errors; |
144 } | 146 } |
145 | 147 |
| 148 // static |
| 149 void TestCase::QuitMainMessageLoop(PP_Instance instance) { |
| 150 PP_Instance* heap_instance = new PP_Instance(instance); |
| 151 pp::CompletionCallback callback(&DoQuitMainMessageLoop, heap_instance); |
| 152 pp::Module::Get()->core()->CallOnMainThread(0, callback); |
| 153 } |
146 | 154 |
| 155 // static |
| 156 void TestCase::DoQuitMainMessageLoop(void* pp_instance, int32_t result) { |
| 157 PP_Instance* instance = static_cast<PP_Instance*>(pp_instance); |
| 158 GetTestingInterface()->QuitMessageLoop(*instance); |
| 159 delete instance; |
| 160 } |
| 161 |
OLD | NEW |