Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [diff] [blame] | 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 | */ |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 16 | |
| 17 | #include "class_linker.h" |
| 18 | #include "common_test.h" |
| 19 | #include "dex_cache.h" |
| 20 | #include "heap.h" |
| 21 | #include "object.h" |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 22 | |
| 23 | #include <stdio.h> |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 24 | |
| 25 | namespace art { |
| 26 | |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 27 | class DexCacheTest : public CommonTest {}; |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 28 | |
| 29 | TEST_F(DexCacheTest, Open) { |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 30 | SirtRef<DexCache> dex_cache(class_linker_->AllocDexCache(*java_lang_dex_file_)); |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame] | 31 | ASSERT_TRUE(dex_cache.get() != NULL); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 32 | |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 33 | EXPECT_EQ(java_lang_dex_file_->NumStringIds(), dex_cache->NumStrings()); |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 34 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), dex_cache->NumResolvedTypes()); |
| 35 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), dex_cache->NumResolvedMethods()); |
| 36 | EXPECT_EQ(java_lang_dex_file_->NumFieldIds(), dex_cache->NumResolvedFields()); |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 37 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), dex_cache->NumInitializedStaticStorage()); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 38 | |
| 39 | EXPECT_LE(0, dex_cache->GetStrings()->GetLength()); |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 40 | EXPECT_LE(0, dex_cache->GetResolvedTypes()->GetLength()); |
| 41 | EXPECT_LE(0, dex_cache->GetResolvedMethods()->GetLength()); |
| 42 | EXPECT_LE(0, dex_cache->GetResolvedFields()->GetLength()); |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 43 | EXPECT_LE(0, dex_cache->GetInitializedStaticStorage()->GetLength()); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 44 | |
| 45 | EXPECT_EQ(java_lang_dex_file_->NumStringIds(), |
| 46 | static_cast<uint32_t>(dex_cache->GetStrings()->GetLength())); |
| 47 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 48 | static_cast<uint32_t>(dex_cache->GetResolvedTypes()->GetLength())); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 49 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 50 | static_cast<uint32_t>(dex_cache->GetResolvedMethods()->GetLength())); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 51 | EXPECT_EQ(java_lang_dex_file_->NumFieldIds(), |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 52 | static_cast<uint32_t>(dex_cache->GetResolvedFields()->GetLength())); |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 53 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), |
| 54 | static_cast<uint32_t>(dex_cache->GetInitializedStaticStorage()->GetLength())); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | } // namespace art |