1 /* 2 * Copyright (C) 2017 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 "test/Common.h" 18 19 using android::ConfigDescription; 20 21 namespace aapt { 22 namespace test { 23 24 struct DummyDiagnosticsImpl : public IDiagnostics { 25 void Log(Level level, DiagMessageActual& actual_msg) override { 26 switch (level) { 27 case Level::Note: 28 return; 29 30 case Level::Warn: 31 std::cerr << actual_msg.source << ": warn: " << actual_msg.message << "." << std::endl; 32 break; 33 34 case Level::Error: 35 std::cerr << actual_msg.source << ": error: " << actual_msg.message << "." << std::endl; 36 break; 37 } 38 } 39 }; 40 41 IDiagnostics* GetDiagnostics() { 42 static DummyDiagnosticsImpl diag; 43 return &diag; 44 } 45 46 template <> 47 Value* GetValueForConfigAndProduct<Value>(ResourceTable* table, 48 const android::StringPiece& res_name, 49 const ConfigDescription& config, 50 const android::StringPiece& product) { 51 Maybe<ResourceTable::SearchResult> result = table->FindResource(ParseNameOrDie(res_name)); 52 if (result) { 53 ResourceConfigValue* config_value = result.value().entry->FindValue(config, product); 54 if (config_value) { 55 return config_value->value.get(); 56 } 57 } 58 return nullptr; 59 } 60 61 } // namespace test 62 } // namespace aapt 63