1 // Copyright 2022 The gRPC 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 #include <grpc/event_engine/event_engine.h>
15 #include <grpc/grpc.h>
16 #include <grpc/support/port_platform.h>
17
18 #include <memory>
19
20 #include "gmock/gmock.h"
21 #include "gtest/gtest.h"
22 #include "test/core/test_util/test_config.h"
23
24 namespace {
25
26 using ::testing::MockFunction;
27
28 class EventEngineSmokeTest : public testing::Test {};
29
TEST_F(EventEngineSmokeTest,SetEventEngineFactoryLinks)30 TEST_F(EventEngineSmokeTest, SetEventEngineFactoryLinks) {
31 // See https://github.com/grpc/grpc/pull/28707
32 testing::MockFunction<
33 std::unique_ptr<grpc_event_engine::experimental::EventEngine>()>
34 factory;
35 EXPECT_CALL(factory, Call()).Times(1);
36 grpc_event_engine::experimental::SetEventEngineFactory(
37 factory.AsStdFunction());
38 EXPECT_EQ(nullptr, grpc_event_engine::experimental::CreateEventEngine());
39 }
40
41 } // namespace
42
main(int argc,char ** argv)43 int main(int argc, char** argv) {
44 testing::InitGoogleTest(&argc, argv);
45 grpc::testing::TestEnvironment env(&argc, argv);
46 grpc_init();
47 auto result = RUN_ALL_TESTS();
48 grpc_shutdown();
49 return result;
50 }
51