Kevin Rocard | 19b3e43 | 2017-05-24 11:01:34 -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 ANDROID_HARDWARE_AUDIO_TEST_VALIDATEXML |
| 18 | #define ANDROID_HARDWARE_AUDIO_TEST_VALIDATEXML |
| 19 | |
| 20 | #include <gtest/gtest.h> |
| 21 | |
| 22 | namespace android { |
| 23 | namespace hardware { |
| 24 | namespace audio { |
| 25 | namespace test { |
| 26 | |
| 27 | /** Validate the provided XmlFile with the provided xsdFile. |
| 28 | * Intended to use with ASSERT_PRED_FORMAT2 as such: |
| 29 | * ASSERT_PRED_FORMAT2(validateXml, pathToXml, pathToXsd); |
| 30 | * See ASSERT_VALID_XML for a helper macro. |
| 31 | */ |
| 32 | ::testing::AssertionResult validateXml(const char* xmlFilePathExpr, |
| 33 | const char* xsdFilePathExpr, |
| 34 | const char* xmlFilePath, |
| 35 | const char* xsdPathName); |
| 36 | |
| 37 | /** Helper gtest ASSERT to test xml validity against an xsd. */ |
| 38 | #define ASSERT_VALID_XML(xmlFilePath, xsdFilePath) \ |
| 39 | ASSERT_PRED_FORMAT2(::android::hardware::audio::test::validateXml, \ |
| 40 | xmlFilePath, xsdFilePath) |
| 41 | |
| 42 | } // namespace test |
| 43 | } // namespace audio |
| 44 | } // namespace hardware |
| 45 | } // namespace android |
| 46 | |
| 47 | #endif // ANDROID_HARDWARE_AUDIO_TEST_VALIDATEXML |