1 // Copyright 2021 The Tint Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef SRC_INSPECTOR_TEST_INSPECTOR_RUNNER_H_ 16 #define SRC_INSPECTOR_TEST_INSPECTOR_RUNNER_H_ 17 18 #include <memory> 19 #include <string> 20 21 #include "gtest/gtest.h" 22 #include "tint/tint.h" 23 24 namespace tint { 25 namespace inspector { 26 27 /// Utility class for running shaders in inspector tests 28 class InspectorRunner { 29 public: 30 InspectorRunner(); 31 virtual ~InspectorRunner(); 32 33 /// Create a Program with Inspector from the provided WGSL shader. 34 /// Should only be called once per test. 35 /// @param shader a WGSL shader 36 /// @returns a reference to the Inspector for the built Program. 37 Inspector& Initialize(std::string shader); 38 39 protected: 40 /// File created from input shader and used to create Program. 41 std::unique_ptr<Source::File> file_; 42 /// Program created by this runner. 43 std::unique_ptr<Program> program_; 44 /// Inspector for |program_| 45 std::unique_ptr<Inspector> inspector_; 46 }; 47 48 } // namespace inspector 49 } // namespace tint 50 51 #endif // SRC_INSPECTOR_TEST_INSPECTOR_RUNNER_H_ 52