blob: 054f991ccc992b7a9186d64f9f31d08151b68708 [file] [log] [blame]
Brian Carlstrom7e49dca2011-07-22 18:07:34 -07001// 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 Carlstrom7e49dca2011-07-22 18:07:34 -07008
9#include <stdio.h>
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070010
11namespace art {
12
Brian Carlstromf734cf52011-08-17 16:28:14 -070013class DexCacheTest : public CommonTest {};
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070014
15TEST_F(DexCacheTest, Open) {
Brian Carlstrom40381fb2011-10-19 14:13:40 -070016 SirtRef<DexCache> dex_cache(class_linker_->AllocDexCache(*java_lang_dex_file_.get()));
17 ASSERT_TRUE(dex_cache.get() != NULL);
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070018
Brian Carlstroma663ea52011-08-19 23:33:41 -070019 EXPECT_EQ(java_lang_dex_file_->NumStringIds(), dex_cache->NumStrings());
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070020 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 Carlstromc4fa2c02011-08-21 03:00:12 -070025
26 EXPECT_LE(0, dex_cache->GetStrings()->GetLength());
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070027 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 Carlstromc4fa2c02011-08-21 03:00:12 -070032
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 Carlstrom1caa2c22011-08-28 13:02:33 -070036 static_cast<uint32_t>(dex_cache->GetResolvedTypes()->GetLength()));
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070037 EXPECT_EQ(java_lang_dex_file_->NumMethodIds(),
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070038 static_cast<uint32_t>(dex_cache->GetResolvedMethods()->GetLength()));
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070039 EXPECT_EQ(java_lang_dex_file_->NumFieldIds(),
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070040 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 Carlstrom7e49dca2011-07-22 18:07:34 -070045}
46
47} // namespace art