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 | a663ea5 | 2011-08-19 23:33:41 -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()); |
| 23 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), dex_cache->NumClasses()); |
| 24 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), dex_cache->NumMethods()); |
| 25 | EXPECT_EQ(java_lang_dex_file_->NumFieldIds(), dex_cache->NumFields()); |
Brian Carlstrom | c4fa2c0 | 2011-08-21 03:00:12 -0700 | [diff] [blame^] | 26 | |
| 27 | EXPECT_LE(0, dex_cache->GetStrings()->GetLength()); |
| 28 | EXPECT_LE(0, dex_cache->GetClasses()->GetLength()); |
| 29 | EXPECT_LE(0, dex_cache->GetMethods()->GetLength()); |
| 30 | EXPECT_LE(0, dex_cache->GetFields()->GetLength()); |
| 31 | |
| 32 | EXPECT_EQ(java_lang_dex_file_->NumStringIds(), |
| 33 | static_cast<uint32_t>(dex_cache->GetStrings()->GetLength())); |
| 34 | EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), |
| 35 | static_cast<uint32_t>(dex_cache->GetClasses()->GetLength())); |
| 36 | EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), |
| 37 | static_cast<uint32_t>(dex_cache->GetMethods()->GetLength())); |
| 38 | EXPECT_EQ(java_lang_dex_file_->NumFieldIds(), |
| 39 | static_cast<uint32_t>(dex_cache->GetFields()->GetLength())); |
Brian Carlstrom | 7e49dca | 2011-07-22 18:07:34 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | } // namespace art |