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