#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/no_destructor.h"
#include "base/process/process.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/task_environment.h"
#include "base/test/test_suite.h"
#include "base/token.h"
#include "build/build_config.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/constants.h"
#include "services/service_manager/public/cpp/manifest.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_receiver.h"
#include "services/service_manager/public/cpp/test/test_service_manager.h"
#include "services/service_manager/public/mojom/service_manager.mojom.h"
#include "services/service_manager/tests/connect/connect.test-mojom.h"
#include "services/service_manager/tests/util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace service_manager {
namespace {
const char kTestServiceName[] = …;
const char kTestPackageName[] = …;
const char kTestAppName[] = …;
const char kTestExeName[] = …;
const char kTestAppAName[] = …;
const char kTestAppBName[] = …;
const char kTestNonexistentAppName[] = …;
const char kTestSandboxedAppName[] = …;
const char kTestClassAppName[] = …;
const char kTestSingletonAppName[] = …;
const char kIdentityTestCapability[] = …;
const char kConnectTestServiceCapability[] = …;
const char kStandaloneAppControlCapability[] = …;
const char kConnectClassCapability[] = …;
const char kExposedInterfaceCapability[] = …;
const std::vector<Manifest>& GetTestManifests() { … }
void ReceiveOneString(std::string* out_string,
base::RunLoop* loop,
const std::string& in_string) { … }
void ReceiveTwoStrings(std::string* out_string_1,
std::string* out_string_2,
base::RunLoop* loop,
const std::string& in_string_1,
const std::string& in_string_2) { … }
void ReceiveQueryResult(mojom::ServiceInfoPtr* out_info,
base::RunLoop* loop,
mojom::ServiceInfoPtr info) { … }
void ReceiveConnectionResult(mojom::ConnectResult* out_result,
std::optional<Identity>* out_target,
base::RunLoop* loop,
int32_t in_result,
const std::optional<Identity>& in_identity) { … }
void StartServiceResponse(base::RunLoop* quit_loop,
mojom::ConnectResult* out_result,
std::optional<Identity>* out_resolved_identity,
mojom::ConnectResult result,
const std::optional<Identity>& resolved_identity) { … }
void QuitLoop(base::RunLoop* loop) { … }
class TestTargetService : public Service { … };
class ConnectTest : public testing::Test,
public Service,
public test::mojom::ExposedInterface { … };
TEST_F(ConnectTest, BindInterface) { … }
TEST_F(ConnectTest, Instances) { … }
TEST_F(ConnectTest, ConnectWithGloballyUniqueId) { … }
TEST_F(ConnectTest, QueryService) { … }
TEST_F(ConnectTest, QueryNonexistentService) { … }
#if DCHECK_IS_ON()
#define MAYBE_BlockedInterface …
#else
#define MAYBE_BlockedInterface …
#endif
TEST_F(ConnectTest, MAYBE_BlockedInterface) { … }
TEST_F(ConnectTest, AlwaysAllowedInterface) { … }
TEST_F(ConnectTest, PackagedApp) { … }
#if DCHECK_IS_ON()
#define MAYBE_BlockedPackage …
#else
#define MAYBE_BlockedPackage …
#endif
TEST_F(ConnectTest, MAYBE_BlockedPackage) { … }
#if DCHECK_IS_ON()
#define MAYBE_PackagedApp_BlockedInterface …
#else
#define MAYBE_PackagedApp_BlockedInterface …
#endif
TEST_F(ConnectTest, MAYBE_PackagedApp_BlockedInterface) { … }
#if DCHECK_IS_ON()
#define MAYBE_BlockedPackagedApplication …
#else
#define MAYBE_BlockedPackagedApplication …
#endif
TEST_F(ConnectTest, MAYBE_BlockedPackagedApplication) { … }
TEST_F(ConnectTest, CapabilityClasses) { … }
#if DCHECK_IS_ON()
#define MAYBE_ConnectWithoutExplicitClassBlocked …
#else
#define MAYBE_ConnectWithoutExplicitClassBlocked …
#endif
TEST_F(ConnectTest, MAYBE_ConnectWithoutExplicitClassBlocked) { … }
TEST_F(ConnectTest, ConnectToDifferentGroup_Allowed) { … }
TEST_F(ConnectTest, ConnectToDifferentGroup_Blocked) { … }
TEST_F(ConnectTest, ConnectWithDifferentInstanceId_Blocked) { … }
TEST_F(ConnectTest, ConnectToClientProcess_Blocked) { … }
TEST_F(ConnectTest, AllUsersSingleton) { … }
}
}