blob: 71125cca1aaf4815aa3ce3ceecc4717aeda03a31 [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 Carlstroma663ea52011-08-19 23:33:41 -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());
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 Carlstromc4fa2c02011-08-21 03:00:12 -070026
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 Carlstrom7e49dca2011-07-22 18:07:34 -070040}
41
42} // namespace art