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