Home | History | Annotate | Download | only in runtime
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include "dex_method_iterator.h"
     18 
     19 #include "base/stl_util.h"
     20 #include "common_runtime_test.h"
     21 #include "scoped_thread_state_change.h"
     22 #include "thread-inl.h"
     23 
     24 namespace art {
     25 
     26 class DexMethodIteratorTest : public CommonRuntimeTest {
     27 };
     28 
     29 TEST_F(DexMethodIteratorTest, Basic) {
     30   ScopedObjectAccess soa(Thread::Current());
     31   std::vector<const DexFile*> dex_files;
     32   const char* jars[] = { "core-libart", "conscrypt", "okhttp", "core-junit", "bouncycastle" };
     33   for (size_t i = 0; i < 5; ++i) {
     34     dex_files.push_back(LoadExpectSingleDexFile(GetDexFileName(jars[i]).c_str()));
     35   }
     36   DexMethodIterator it(dex_files);
     37   while (it.HasNext()) {
     38     const DexFile& dex_file = it.GetDexFile();
     39     InvokeType invoke_type = it.GetInvokeType();
     40     uint32_t method_idx = it.GetMemberIndex();
     41     if (false) {
     42       LG << invoke_type << " " << PrettyMethod(method_idx, dex_file);
     43     }
     44     it.Next();
     45   }
     46   STLDeleteElements(&dex_files);
     47 }
     48 
     49 }  // namespace art
     50