blob: c1e349fb824f655bd52095d5e05b021368277810 [file] [log] [blame]
Adam Lesinski7a37b742016-10-12 14:05:55 -07001/*
2 * Copyright (C) 2016 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
Adam Lesinskiea789792016-11-10 14:33:11 -080017#ifndef TEST_HELPERS_H_
18#define TEST_HELPERS_H_
Adam Lesinski7a37b742016-10-12 14:05:55 -070019
20#include <ostream>
21#include <string>
22
Adam Lesinskiea789792016-11-10 14:33:11 -080023#include "androidfw/ResourceTypes.h"
24#include "gtest/gtest.h"
25#include "utils/String16.h"
26#include "utils/String8.h"
Adam Lesinskif90f2f8d2014-06-06 14:27:00 -070027
Adam Lesinskiea789792016-11-10 14:33:11 -080028static inline ::std::ostream& operator<<(::std::ostream& out,
29 const android::String8& str) {
Adam Lesinski7a37b742016-10-12 14:05:55 -070030 return out << str.string();
Adam Lesinskif90f2f8d2014-06-06 14:27:00 -070031}
32
Adam Lesinskiea789792016-11-10 14:33:11 -080033static inline ::std::ostream& operator<<(::std::ostream& out,
34 const android::String16& str) {
Adam Lesinski7a37b742016-10-12 14:05:55 -070035 return out << android::String8(str).string();
Adam Lesinskif90f2f8d2014-06-06 14:27:00 -070036}
37
Adam Lesinski31245b42014-08-22 19:10:56 -070038namespace android {
39
Adam Lesinski60293192014-10-21 18:36:42 -070040enum { MAY_NOT_BE_BAG = false };
41
Adam Lesinskiea789792016-11-10 14:33:11 -080042void SetTestDataPath(const std::string& path);
43
44const std::string& GetTestDataPath();
45
46static inline bool operator==(const ResTable_config& a,
47 const ResTable_config& b) {
Adam Lesinski7a37b742016-10-12 14:05:55 -070048 return a.compare(b) == 0;
Adam Lesinski31245b42014-08-22 19:10:56 -070049}
50
Adam Lesinskiea789792016-11-10 14:33:11 -080051static inline ::std::ostream& operator<<(::std::ostream& out,
52 const ResTable_config& c) {
Adam Lesinski7a37b742016-10-12 14:05:55 -070053 return out << c.toString().string();
Adam Lesinski31245b42014-08-22 19:10:56 -070054}
55
Adam Lesinskiea789792016-11-10 14:33:11 -080056::testing::AssertionResult IsStringEqual(const ResTable& table,
57 uint32_t resource_id,
Adam Lesinski7a37b742016-10-12 14:05:55 -070058 const char* expected_str);
Adam Lesinski60293192014-10-21 18:36:42 -070059
Adam Lesinski7a37b742016-10-12 14:05:55 -070060} // namespace android
Adam Lesinski31245b42014-08-22 19:10:56 -070061
Adam Lesinskiea789792016-11-10 14:33:11 -080062#endif // TEST_HELPERS_H_