TestHelpers.h revision 4c67a475a334e4f65238d439a3339195e03c03be
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 17#ifndef TEST_HELPERS_H_ 18#define TEST_HELPERS_H_ 19 20#include <ostream> 21#include <string> 22 23#include "androidfw/ResourceTypes.h" 24#include "gtest/gtest.h" 25#include "utils/String16.h" 26#include "utils/String8.h" 27 28static inline ::std::ostream& operator<<(::std::ostream& out, const android::String8& str) { 29 return out << str.string(); 30} 31 32static inline ::std::ostream& operator<<(::std::ostream& out, const android::String16& str) { 33 return out << android::String8(str).string(); 34} 35 36namespace android { 37 38enum { MAY_NOT_BE_BAG = false }; 39 40void SetTestDataPath(const std::string& path); 41 42const std::string& GetTestDataPath(); 43 44::testing::AssertionResult ReadFileFromZipToString(const std::string& zip_path, 45 const std::string& file, 46 std::string* out_contents); 47 48static inline bool operator==(const ResTable_config& a, const ResTable_config& b) { 49 return a.compare(b) == 0; 50} 51 52static inline ::std::ostream& operator<<(::std::ostream& out, const ResTable_config& c) { 53 return out << c.toString().string(); 54} 55 56::testing::AssertionResult IsStringEqual(const ResTable& table, uint32_t resource_id, 57 const char* expected_str); 58 59} // namespace android 60 61#endif // TEST_HELPERS_H_ 62