1265091e581c9f643b37e7966890911f09e223269Brian Carlstrom/* 2265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * Copyright (C) 2011 The Android Open Source Project 3265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * 4265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * Licensed under the Apache License, Version 2.0 (the "License"); 5265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * you may not use this file except in compliance with the License. 6265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * You may obtain a copy of the License at 7265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * 8265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * http://www.apache.org/licenses/LICENSE-2.0 9265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * 10265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * Unless required by applicable law or agreed to in writing, software 11265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * distributed under the License is distributed on an "AS IS" BASIS, 12265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * See the License for the specific language governing permissions and 14265091e581c9f643b37e7966890911f09e223269Brian Carlstrom * limitations under the License. 15265091e581c9f643b37e7966890911f09e223269Brian Carlstrom */ 16265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 17265091e581c9f643b37e7966890911f09e223269Brian Carlstrom#include "dex_method_iterator.h" 18265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 19e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "base/stl_util.h" 20a1ce1fef2d49d1d537776a5308ace7102a815fe5Brian Carlstrom#include "common_runtime_test.h" 21e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "scoped_thread_state_change.h" 22e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "thread-inl.h" 23265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 24265091e581c9f643b37e7966890911f09e223269Brian Carlstromnamespace art { 25265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 26a1ce1fef2d49d1d537776a5308ace7102a815fe5Brian Carlstromclass DexMethodIteratorTest : public CommonRuntimeTest { 278d31bbd3d6536de12bc20e3d29cfe03fe848f9daIan Rogers}; 28265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 29265091e581c9f643b37e7966890911f09e223269Brian CarlstromTEST_F(DexMethodIteratorTest, Basic) { 30265091e581c9f643b37e7966890911f09e223269Brian Carlstrom ScopedObjectAccess soa(Thread::Current()); 31265091e581c9f643b37e7966890911f09e223269Brian Carlstrom std::vector<const DexFile*> dex_files; 32833a48501d560c9fa7fc78ef619888138c2d374fAndreas Gampe const char* jars[] = { "core-libart", "conscrypt", "okhttp", "core-junit", "bouncycastle" }; 33833a48501d560c9fa7fc78ef619888138c2d374fAndreas Gampe for (size_t i = 0; i < 5; ++i) { 34833a48501d560c9fa7fc78ef619888138c2d374fAndreas Gampe dex_files.push_back(LoadExpectSingleDexFile(GetDexFileName(jars[i]).c_str())); 35833a48501d560c9fa7fc78ef619888138c2d374fAndreas Gampe } 36265091e581c9f643b37e7966890911f09e223269Brian Carlstrom DexMethodIterator it(dex_files); 37265091e581c9f643b37e7966890911f09e223269Brian Carlstrom while (it.HasNext()) { 38265091e581c9f643b37e7966890911f09e223269Brian Carlstrom const DexFile& dex_file = it.GetDexFile(); 39265091e581c9f643b37e7966890911f09e223269Brian Carlstrom InvokeType invoke_type = it.GetInvokeType(); 40265091e581c9f643b37e7966890911f09e223269Brian Carlstrom uint32_t method_idx = it.GetMemberIndex(); 41265091e581c9f643b37e7966890911f09e223269Brian Carlstrom if (false) { 42265091e581c9f643b37e7966890911f09e223269Brian Carlstrom LG << invoke_type << " " << PrettyMethod(method_idx, dex_file); 43265091e581c9f643b37e7966890911f09e223269Brian Carlstrom } 44265091e581c9f643b37e7966890911f09e223269Brian Carlstrom it.Next(); 45265091e581c9f643b37e7966890911f09e223269Brian Carlstrom } 46265091e581c9f643b37e7966890911f09e223269Brian Carlstrom STLDeleteElements(&dex_files); 47265091e581c9f643b37e7966890911f09e223269Brian Carlstrom} 48265091e581c9f643b37e7966890911f09e223269Brian Carlstrom 49265091e581c9f643b37e7966890911f09e223269Brian Carlstrom} // namespace art 50