blob: 6ecaa182257405d4021124e0ea45a0dee4bad8ee [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 Carlstrom9ea1cb12011-08-24 23:18:18 -070023 EXPECT_EQ(java_lang_dex_file_->NumTypeIds(), dex_cache->NumTypes());
Brian Carlstroma663ea52011-08-19 23:33:41 -070024 EXPECT_EQ(java_lang_dex_file_->NumMethodIds(), dex_cache->NumMethods());
25 EXPECT_EQ(java_lang_dex_file_->NumFieldIds(), dex_cache->NumFields());
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070026
27 EXPECT_LE(0, dex_cache->GetStrings()->GetLength());
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070028 EXPECT_LE(0, dex_cache->GetTypes()->GetLength());
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070029 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(),
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070035 static_cast<uint32_t>(dex_cache->GetTypes()->GetLength()));
Brian Carlstromc4fa2c02011-08-21 03:00:12 -070036 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 Carlstrom7e49dca2011-07-22 18:07:34 -070040}
41
42} // namespace art