1 /*
2 * Copyright 2020 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 #include "dumpsys/reflection_schema.h"
18
19 #include <gtest/gtest.h>
20
21 #include "dumpsys/dumpsys_test_data.h"
22
23 namespace bluetooth {
24 namespace dumpsys {
25 extern const unsigned char* data;
26 extern const size_t data_size;
27 const std::string& GetBundledSchemaData();
28 } // namespace dumpsys
29 } // namespace bluetooth
30
31 namespace testing {
32
33 using namespace bluetooth;
34
35 class ReflectionSchemaTest : public Test {
36 protected:
SetUp()37 void SetUp() override {}
38
TearDown()39 void TearDown() override {}
40 };
41
TEST_F(ReflectionSchemaTest,verify_test_content)42 TEST_F(ReflectionSchemaTest, verify_test_content) {
43 dumpsys::ReflectionSchema reflection_schema(testing::GetBundledSchemaData());
44 ASSERT_TRUE(reflection_schema.GetNumberOfBundledSchemas() == 5);
45 ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.DumpsysTestDataRoot") != nullptr);
46 ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.BarTestSchema") != nullptr);
47 ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.BazTestSchema") != nullptr);
48 ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.FooTestSchema") != nullptr);
49 ASSERT_TRUE(reflection_schema.FindInReflectionSchema("testing.QuxTestSchema") != nullptr);
50 ASSERT_TRUE(reflection_schema.FindInReflectionSchema("DoesNotExist") == nullptr);
51 }
52
TEST_F(ReflectionSchemaTest,verify_test_schema)53 TEST_F(ReflectionSchemaTest, verify_test_schema) {
54 dumpsys::ReflectionSchema reflection_schema(testing::GetBundledSchemaData());
55 ASSERT_TRUE(reflection_schema.VerifyReflectionSchema());
56 }
57
TEST_F(ReflectionSchemaTest,verify_production_schema)58 TEST_F(ReflectionSchemaTest, verify_production_schema) {
59 dumpsys::ReflectionSchema reflection_schema(bluetooth::dumpsys::GetBundledSchemaData());
60 ASSERT_TRUE(reflection_schema.VerifyReflectionSchema());
61 }
62
63 } // namespace testing
64