xref: /aosp_15_r20/external/grpc-grpc/src/objective-c/tests/EventEngineTests/CFEventEngineClientTests.mm (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1/*
2 *
3 * Copyright 2023 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19#import <XCTest/XCTest.h>
20
21#include <grpc/grpc.h>
22
23#include "src/core/lib/event_engine/cf_engine/cf_engine.h"
24#include "test/core/event_engine/test_suite/event_engine_test_framework.h"
25#include "test/core/event_engine/test_suite/posix/oracle_event_engine_posix.h"
26#include "test/core/event_engine/test_suite/tests/client_test.h"
27#include "test/core/util/test_config.h"
28
29@interface EventEngineTimerTests : XCTestCase
30@end
31
32@implementation EventEngineTimerTests
33
34- (void)testAll {
35  NSArray *arguments = [NSProcessInfo processInfo].arguments;
36  int argc = (int)arguments.count;
37  char **argv = static_cast<char **>(alloca((sizeof(char *) * (argc + 1))));
38  for (int index = 0; index < argc; index++) {
39    argv[index] = const_cast<char *>([arguments[index] UTF8String]);
40  }
41  argv[argc] = NULL;
42
43  testing::InitGoogleTest(&argc, (char **)argv);
44  grpc::testing::TestEnvironment env(&argc, (char **)argv);
45
46  auto factory = []() {
47    return std::make_unique<grpc_event_engine::experimental::CFEventEngine>();
48  };
49  auto oracle_factory = []() {
50    return std::make_unique<grpc_event_engine::experimental::PosixOracleEventEngine>();
51  };
52  SetEventEngineFactories(factory, oracle_factory);
53  grpc_event_engine::experimental::InitClientTests();
54  // TODO(ctiller): EventEngine temporarily needs grpc to be initialized first
55  // until we clear out the iomgr shutdown code.
56  grpc_init();
57  int r = RUN_ALL_TESTS();
58  grpc_shutdown();
59
60  XCTAssertEqual(r, 0);
61}
62
63@end
64