blob: 5f0c455211ecd7125b68f80b902d6a7e95af52c9 [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 Lesinskif90f2f8d2014-06-06 14:27:00 -070017#ifndef __TEST_HELPERS_H
18#define __TEST_HELPERS_H
19
Adam Lesinski31245b42014-08-22 19:10:56 -070020#include <androidfw/ResourceTypes.h>
Adam Lesinski60293192014-10-21 18:36:42 -070021#include <gtest/gtest.h>
Adam Lesinski7a37b742016-10-12 14:05:55 -070022#include <utils/String16.h>
23#include <utils/String8.h>
24
25#include <ostream>
26#include <string>
27
28std::string TestSourceDir();
Adam Lesinskif90f2f8d2014-06-06 14:27:00 -070029
30static inline ::std::ostream& operator<<(::std::ostream& out, const android::String8& str) {
Adam Lesinski7a37b742016-10-12 14:05:55 -070031 return out << str.string();
Adam Lesinskif90f2f8d2014-06-06 14:27:00 -070032}
33
34static inline ::std::ostream& operator<<(::std::ostream& out, 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 Lesinski7a37b742016-10-12 14:05:55 -070042static inline bool operator==(const android::ResTable_config& a,
43 const android::ResTable_config& b) {
44 return a.compare(b) == 0;
Adam Lesinski31245b42014-08-22 19:10:56 -070045}
46
47static inline ::std::ostream& operator<<(::std::ostream& out, const android::ResTable_config& c) {
Adam Lesinski7a37b742016-10-12 14:05:55 -070048 return out << c.toString().string();
Adam Lesinski31245b42014-08-22 19:10:56 -070049}
50
Adam Lesinski7a37b742016-10-12 14:05:55 -070051::testing::AssertionResult IsStringEqual(const ResTable& table, uint32_t resource_id,
52 const char* expected_str);
Adam Lesinski60293192014-10-21 18:36:42 -070053
Adam Lesinski7a37b742016-10-12 14:05:55 -070054} // namespace android
Adam Lesinski31245b42014-08-22 19:10:56 -070055
Adam Lesinski7a37b742016-10-12 14:05:55 -070056#endif // __TEST_HELPERS_H