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