1 /*
2  * Copyright (C) 2014 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 H_AAPT_SPLIT_TEST_RULES
18 #define H_AAPT_SPLIT_TEST_RULES
19 
20 #include "Rule.h"
21 
22 #include <gtest/gtest.h>
23 
24 namespace split {
25 namespace test {
26 
27 struct AndRule : public Rule {
AndRuleAndRule28     AndRule() {
29         op = Rule::AND_SUBRULES;
30     }
31 
addAndRule32     AndRule& add(const Rule& rhs) {
33         subrules.add(new Rule(rhs));
34         return *this;
35     }
36 };
37 
38 struct OrRule : public Rule {
OrRuleOrRule39     OrRule() {
40         op = Rule::OR_SUBRULES;
41     }
42 
addOrRule43     OrRule& add(const Rule& rhs) {
44         subrules.add(new Rule(rhs));
45         return *this;
46     }
47 };
48 
49 const Rule EqRule(Rule::Key key, long value);
50 const Rule LtRule(Rule::Key key, long value);
51 const Rule GtRule(Rule::Key key, long value);
52 const Rule ContainsAnyRule(Rule::Key key, const char* str1);
53 const Rule ContainsAnyRule(Rule::Key key, const char* str1, const char* str2);
54 const Rule AlwaysTrue();
55 
56 ::testing::AssertionResult RulePredFormat(
57         const char* actualExpr, const char* expectedExpr,
58         const android::sp<Rule>& actual, const Rule& expected);
59 
60 #define EXPECT_RULES_EQ(actual, expected) \
61         EXPECT_PRED_FORMAT2(::split::test::RulePredFormat, actual, expected)
62 
63 } // namespace test
64 } // namespace split
65 
66 #endif // H_AAPT_SPLIT_TEST_RULES
67