Adam Lesinski | 873ef0e | 2017-10-11 16:50:37 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | #ifndef ANDROIDFW_TEST_COMMON_HELPERS_H |
| 18 | #define ANDROIDFW_TEST_COMMON_HELPERS_H |
| 19 | |
| 20 | #include <ostream> |
| 21 | #include <string> |
| 22 | |
| 23 | #include "androidfw/ResourceTypes.h" |
| 24 | #include "utils/String16.h" |
| 25 | #include "utils/String8.h" |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | void InitializeTest(int* argc, char** argv); |
| 30 | |
| 31 | enum { MAY_NOT_BE_BAG = false }; |
| 32 | |
| 33 | void SetTestDataPath(const std::string& path); |
| 34 | |
| 35 | const std::string& GetTestDataPath(); |
| 36 | |
| 37 | std::string GetStringFromPool(const ResStringPool* pool, uint32_t idx); |
| 38 | |
| 39 | static inline bool operator==(const ResTable_config& a, const ResTable_config& b) { |
| 40 | return a.compare(b) == 0; |
| 41 | } |
| 42 | |
| 43 | static inline ::std::ostream& operator<<(::std::ostream& out, const String8& str) { |
| 44 | return out << str.string(); |
| 45 | } |
| 46 | |
| 47 | static inline ::std::ostream& operator<<(::std::ostream& out, const String16& str) { |
| 48 | return out << String8(str).string(); |
| 49 | } |
| 50 | |
| 51 | static inline ::std::ostream& operator<<(::std::ostream& out, const ResTable_config& c) { |
| 52 | return out << c.toString(); |
| 53 | } |
| 54 | |
| 55 | } // namespace android |
| 56 | |
| 57 | #endif // ANDROIDFW_TEST_COMMON_HELPERS_H |