1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17 #include "Log.h" 18 #include "Report.h" 19 20 #include "task/TaskBatch.h" 21 22 static const android::String8 STR_NAME("name"); 23 static const android::String8 STR_VERSION("version"); 24 static const android::String8 STR_DESCRIPTION("description"); 25 26 TaskBatch::TaskBatch() 27 :TaskGeneric(TaskGeneric::ETaskBatch) 28 { 29 const android::String8* list[] = {&STR_NAME, &STR_VERSION, &STR_DESCRIPTION, NULL}; 30 registerSupportedStringAttributes(list); 31 } 32 33 TaskBatch::~TaskBatch() 34 { 35 36 } 37 38 bool TaskBatch::addChild(TaskGeneric* child) 39 { 40 if (child->getType() != TaskGeneric::ETaskCase) { 41 LOGE("TaskBatch::addChild wrong child type %d", child->getType()); 42 return false; 43 } 44 return TaskGeneric::addChild(child); 45 } 46 47 bool runAlways(TaskGeneric* child, void* data) 48 { 49 child->run(); 50 return true; 51 } 52 53 TaskGeneric::ExecutionResult TaskBatch::run() 54 { 55 android::String8 name; 56 android::String8 version; 57 58 if (!findStringAttribute(STR_NAME, name) || !findStringAttribute(STR_VERSION, version)) { 59 LOGW("TaskBatch::run no name or version information"); 60 } 61 MSG("= Test batch %s version %s started. =", name.string(), 62 version.string()); 63 bool result = TaskGeneric::forEachChild(runAlways, NULL); 64 MSG("= Finished Test batch ="); 65 return TaskGeneric::EResultOK; 66 } 67 68 69