1 /* 2 * Copyright (C) 2019 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 #pragma once 18 19 #include <string> 20 21 #include <gmock/gmock.h> 22 #include <jsonpb/json_schema_test.h> 23 24 #include "task_profiles.pb.h" 25 26 namespace android { 27 namespace profiles { 28 29 class TaskProfilesTest : public jsonpb::JsonSchemaTest { 30 public: SetUp()31 void SetUp() override { 32 JsonSchemaTest::SetUp(); 33 task_profiles_ = static_cast<TaskProfiles*>(message()); 34 } 35 TaskProfiles* task_profiles_; 36 }; 37 TEST_P(TaskProfilesTest,AttributeRequiredFields)38TEST_P(TaskProfilesTest, AttributeRequiredFields) { 39 for (int i = 0; i < task_profiles_->attributes_size(); ++i) { 40 auto&& attribute = task_profiles_->attributes(i); 41 EXPECT_FALSE(attribute.name().empty()) 42 << "No name for attribute #" << i << " in " << file_path_; 43 EXPECT_FALSE(attribute.controller().empty()) 44 << "No controller for attribute #" << i << " in " << file_path_; 45 EXPECT_FALSE(attribute.file().empty()) 46 << "No file for attribute #" << i << " in " << file_path_; 47 } 48 } 49 TEST_P(TaskProfilesTest,ProfileRequiredFields)50TEST_P(TaskProfilesTest, ProfileRequiredFields) { 51 for (int profile_idx = 0; profile_idx < task_profiles_->profiles_size(); ++profile_idx) { 52 auto&& profile = task_profiles_->profiles(profile_idx); 53 EXPECT_FALSE(profile.name().empty()) 54 << "No name for profile #" << profile_idx << " in " << file_path_; 55 for (int action_idx = 0; action_idx < profile.actions_size(); ++action_idx) { 56 auto&& action = profile.actions(action_idx); 57 EXPECT_FALSE(action.name().empty()) 58 << "No name for profiles[" << profile_idx << "].actions[" << action_idx 59 << "] in " << file_path_; 60 } 61 } 62 } 63 64 } // namespace profiles 65 } // namespace android 66