2 * Copyright 2019 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "stack_manager.h"
19 #include "gtest/gtest.h"
20 #include "os/thread.h"
25 TEST(StackManagerTest, start_and_shutdown_no_module) {
26 StackManager stack_manager;
27 ModuleList module_list;
28 os::Thread thread{"test_thread", os::Thread::Priority::NORMAL};
29 stack_manager.StartUp(&module_list, &thread);
30 stack_manager.ShutDown();
33 class TestModuleNoDependency : public Module {
35 static const ModuleFactory Factory;
38 void ListDependencies(ModuleList* list) override {}
39 void Start() override {}
40 void Stop() override {}
41 std::string ToString() const override {
42 return std::string("TestModuleDep");
46 const ModuleFactory TestModuleNoDependency::Factory = ModuleFactory([]() { return new TestModuleNoDependency(); });
48 TEST(StackManagerTest, get_module_instance) {
49 StackManager stack_manager;
50 ModuleList module_list;
51 module_list.add<TestModuleNoDependency>();
52 os::Thread thread{"test_thread", os::Thread::Priority::NORMAL};
53 stack_manager.StartUp(&module_list, &thread);
54 EXPECT_NE(stack_manager.GetInstance<TestModuleNoDependency>(), nullptr);
55 stack_manager.ShutDown();
59 } // namespace bluetooth