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 #ifndef CTSAUDIO_REPORT_H 18 #define CTSAUDIO_REPORT_H 19 20 #include <list> 21 22 #include <utils/String8.h> 23 #include "FileUtil.h" 24 /** 25 * Class to generate report 26 */ 27 class Report: public FileUtil { 28 public: 29 /** 30 * returns static instance of Report 31 * report without dir name, for the 1st call, will only print to stdout. 32 * This mode is necessary to prevent creating tons of reports during unit testing 33 */ 34 static Report* Instance(const char* dirName = NULL); 35 // should be called before finishing to flush the report to file system 36 static void Finalize(); 37 38 void addCasePassed(const android::String8& name); 39 void addCaseFailed(const android::String8& name); 40 void printf(const char* fmt, ...); 41 42 private: 43 Report(); 44 ~Report(); 45 bool init(const char* dirName); 46 void writeSummary(); 47 48 private: 49 static Report* mInstance; 50 std::list<android::String8> mPassedCases; 51 std::list<android::String8> mFailedCases; 52 }; 53 54 55 #endif // CTSAUDIO_REPORT_H 56