Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 1 | /* |
| 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 Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 17 | #ifndef TEST_HELPERS_H_ |
| 18 | #define TEST_HELPERS_H_ |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 19 | |
| 20 | #include <ostream> |
| 21 | #include <string> |
| 22 | |
Adam Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 23 | #include "androidfw/ResourceTypes.h" |
| 24 | #include "gtest/gtest.h" |
| 25 | #include "utils/String16.h" |
| 26 | #include "utils/String8.h" |
Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 27 | |
Adam Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 28 | static inline ::std::ostream& operator<<(::std::ostream& out, |
| 29 | const android::String8& str) { |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 30 | return out << str.string(); |
Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Adam Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 33 | static inline ::std::ostream& operator<<(::std::ostream& out, |
| 34 | const android::String16& str) { |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 35 | return out << android::String8(str).string(); |
Adam Lesinski | f90f2f8d | 2014-06-06 14:27:00 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Adam Lesinski | 31245b4 | 2014-08-22 19:10:56 -0700 | [diff] [blame] | 38 | namespace android { |
| 39 | |
Adam Lesinski | 6029319 | 2014-10-21 18:36:42 -0700 | [diff] [blame] | 40 | enum { MAY_NOT_BE_BAG = false }; |
| 41 | |
Adam Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 42 | void SetTestDataPath(const std::string& path); |
| 43 | |
| 44 | const std::string& GetTestDataPath(); |
| 45 | |
| 46 | static inline bool operator==(const ResTable_config& a, |
| 47 | const ResTable_config& b) { |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 48 | return a.compare(b) == 0; |
Adam Lesinski | 31245b4 | 2014-08-22 19:10:56 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Adam Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 51 | static inline ::std::ostream& operator<<(::std::ostream& out, |
| 52 | const ResTable_config& c) { |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 53 | return out << c.toString().string(); |
Adam Lesinski | 31245b4 | 2014-08-22 19:10:56 -0700 | [diff] [blame] | 54 | } |
| 55 | |
Adam Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 56 | ::testing::AssertionResult IsStringEqual(const ResTable& table, |
| 57 | uint32_t resource_id, |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 58 | const char* expected_str); |
Adam Lesinski | 6029319 | 2014-10-21 18:36:42 -0700 | [diff] [blame] | 59 | |
Adam Lesinski | 7a37b74 | 2016-10-12 14:05:55 -0700 | [diff] [blame] | 60 | } // namespace android |
Adam Lesinski | 31245b4 | 2014-08-22 19:10:56 -0700 | [diff] [blame] | 61 | |
Adam Lesinski | ea78979 | 2016-11-10 14:33:11 -0800 | [diff] [blame^] | 62 | #endif // TEST_HELPERS_H_ |