1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <androidfw/ResourceTypes.h>
18 
19 #include <utils/String8.h>
20 #include <utils/String16.h>
21 #include "TestHelpers.h"
22 #include "data/system/R.h"
23 #include "data/app/R.h"
24 
25 #include <gtest/gtest.h>
26 
27 using namespace android;
28 
29 namespace {
30 
31 #include "data/system/system_arsc.h"
32 #include "data/app/app_arsc.h"
33 
34 enum { MAY_NOT_BE_BAG = false };
35 
36 /**
37  * TODO(adamlesinski): Enable when fixed.
38  */
TEST(ThemeTest,DISABLED_shouldCopyThemeFromDifferentResTable)39 TEST(ThemeTest, DISABLED_shouldCopyThemeFromDifferentResTable) {
40     ResTable table;
41     ASSERT_EQ(NO_ERROR, table.add(system_arsc, system_arsc_len));
42     ASSERT_EQ(NO_ERROR, table.add(app_arsc, app_arsc_len));
43 
44     ResTable::Theme theme1(table);
45     ASSERT_EQ(NO_ERROR, theme1.applyStyle(app::R::style::Theme_One));
46     Res_value val;
47     ASSERT_GE(theme1.getAttribute(android::R::attr::background, &val), 0);
48     ASSERT_EQ(Res_value::TYPE_INT_COLOR_RGB8, val.dataType);
49     ASSERT_EQ(uint32_t(0xffff0000), val.data);
50     ASSERT_GE(theme1.getAttribute(app::R::attr::number, &val), 0);
51     ASSERT_EQ(Res_value::TYPE_INT_DEC, val.dataType);
52     ASSERT_EQ(uint32_t(1), val.data);
53 
54     ResTable table2;
55     ASSERT_EQ(NO_ERROR, table2.add(system_arsc, system_arsc_len));
56     ASSERT_EQ(NO_ERROR, table2.add(app_arsc, app_arsc_len));
57 
58     ResTable::Theme theme2(table2);
59     ASSERT_EQ(NO_ERROR, theme2.setTo(theme1));
60     ASSERT_GE(theme2.getAttribute(android::R::attr::background, &val), 0);
61     ASSERT_EQ(Res_value::TYPE_INT_COLOR_RGB8, val.dataType);
62     ASSERT_EQ(uint32_t(0xffff0000), val.data);
63     ASSERT_GE(theme2.getAttribute(app::R::attr::number, &val), 0);
64     ASSERT_EQ(Res_value::TYPE_INT_DEC, val.dataType);
65     ASSERT_EQ(uint32_t(1), val.data);
66 }
67 
68 }
69