blob: 4c0939af932cd48b3fb1bfc835af240e93bb8d9e [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"
8#include "scoped_ptr.h"
9
10#include <stdio.h>
11#include "gtest/gtest.h"
12
13namespace art {
14
Brian Carlstromf734cf52011-08-17 16:28:14 -070015class DexCacheTest : public CommonTest {};
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070016
17TEST_F(DexCacheTest, Open) {
18
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070019 DexCache* dex_cache = class_linker_->AllocDexCache(*java_lang_dex_file_.get());
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070020 ASSERT_TRUE(dex_cache != NULL);
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070021
Brian Carlstroma663ea52011-08-19 23:33:41 -070022 EXPECT_EQ(java_lang_dex_file_->NumStringIds(), dex_cache->NumStrings());
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070023 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 Carlstromc4fa2c02011-08-21 03:00:12 -070028
29 EXPECT_LE(0, dex_cache->GetStrings()->GetLength());
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070030 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 Carlstromc4fa2c02011-08-21 03:00:12 -070035
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 Carlstrom1caa2c22011-08-28 13:02:33 -070039 static_cast<uint32_t>(dex_cache->GetResolvedTypes()->GetLength()));
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070040 EXPECT_EQ(java_lang_dex_file_->NumMethodIds(),
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070041 static_cast<uint32_t>(dex_cache->GetResolvedMethods()->GetLength()));
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070042 EXPECT_EQ(java_lang_dex_file_->NumFieldIds(),
Brian Carlstrom1caa2c22011-08-28 13:02:33 -070043 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 Carlstrom7e49dca2011-07-22 18:07:34 -070048}
49
50} // namespace art