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