Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include "class_linker.h" |
| 4 | #include "common_test.h" |
| 5 | #include "dex_cache.h" |
| 6 | #include "heap.h" |
| 7 | #include "object.h" |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 8 | |
| 9 | #include <stdio.h> |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 10 | |
| 11 | namespace art { |
| 12 | |
Brian Carlstrom | f734cf5 | 2011-08-17 16:28:14 -0700 | [diff] [blame] | 13 | class DexCacheTest : public CommonTest {}; |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 14 | |
| 15 | TEST_F(DexCacheTest, Open) { |
Brian Carlstrom | 40381fb | 2011-10-19 14:13:40 -0700 | [diff] [blame^] | 16 | SirtRef<DexCache> dex_cache(class_linker_->AllocDexCache(*java_lang_dex_file_.get())); |
| 17 | ASSERT_TRUE(dex_cache.get() != NULL); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 18 | |
Brian Carlstrom | a663ea5 | 2011-08-19 23:33:41 -0700 | [diff] [blame] | 19 | EXPECT_EQ(java_lang_dex_file_->NumStringIds(), dex_cache->NumStrings()); |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 20 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), dex_cache->NumResolvedTypes()); |
| 21 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), dex_cache->NumResolvedMethods()); |
| 22 | EXPECT_EQ(java_lang_dex_file_->NumFieldIds(), dex_cache->NumResolvedFields()); |
| 23 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), dex_cache->NumCodeAndDirectMethods()); |
| 24 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), dex_cache->NumInitializedStaticStorage()); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 25 | |
| 26 | EXPECT_LE(0, dex_cache->GetStrings()->GetLength()); |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 27 | EXPECT_LE(0, dex_cache->GetResolvedTypes()->GetLength()); |
| 28 | EXPECT_LE(0, dex_cache->GetResolvedMethods()->GetLength()); |
| 29 | EXPECT_LE(0, dex_cache->GetResolvedFields()->GetLength()); |
| 30 | EXPECT_LE(0, dex_cache->GetCodeAndDirectMethods()->GetLength()); |
| 31 | EXPECT_LE(0, dex_cache->GetInitializedStaticStorage()->GetLength()); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 32 | |
| 33 | EXPECT_EQ(java_lang_dex_file_->NumStringIds(), |
| 34 | static_cast<uint32_t>(dex_cache->GetStrings()->GetLength())); |
| 35 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 36 | static_cast<uint32_t>(dex_cache->GetResolvedTypes()->GetLength())); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 37 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 38 | static_cast<uint32_t>(dex_cache->GetResolvedMethods()->GetLength())); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame] | 39 | EXPECT_EQ(java_lang_dex_file_->NumFieldIds(), |
Brian Carlstrom | 1caa2c2 | 2011-08-28 13:02:33 -0700 | [diff] [blame] | 40 | static_cast<uint32_t>(dex_cache->GetResolvedFields()->GetLength())); |
| 41 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), |
| 42 | static_cast<uint32_t>(dex_cache->GetCodeAndDirectMethods()->NumCodeAndDirectMethods())); |
| 43 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), |
| 44 | static_cast<uint32_t>(dex_cache->GetInitializedStaticStorage()->GetLength())); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | } // namespace art |