class MockLoaderService

Defined at line 40 of file ../../sdk/lib/ld/testing/include/lib/ld/testing/mock-loader-service.h

MockLoaderService is a mock interface for testing that specific requests

are made over the fuchsia.ldsvc.Loader protocol. It is controlled by the

MockLoaderServiceForTest class (see below).

This class initializes a mock server that serves the fuchsia.ldsvc.Loader

protocol and provides a reference to a FIDL client to make requests with.

`Expect*` handlers are provided for each protocol request so that the test

caller may add an expectation that the method is called and define what the

mock server should return in its response. For example:

```

MockLoaderService mock_loader_service;

ASSERT_NO_FATAL_FAILURE(mock_loader_service.Init());

mock_loader_service.ExpectLoadObject("foo.so", zx::ok(zx::vmo()));

...

```

The private `MockServer` is a StrictMock that will enforce that the test

calls the `Expect*` handler for every request the mock server receives.

If there are multiple Expect* handles set for the MockLoaderService, the

test will verify the requests are made in the order of the Expect* calls.

Public Methods

void MockLoaderService (const MockLoaderService & )

Defined at line 44 of file ../../sdk/lib/ld/testing/include/lib/ld/testing/mock-loader-service.h

void MockLoaderService (MockLoaderService && )

Defined at line 46 of file ../../sdk/lib/ld/testing/include/lib/ld/testing/mock-loader-service.h

bool Ready ()

Returns true if Init() has been called and succeeded.

Defined at line 55 of file ../../sdk/lib/ld/testing/include/lib/ld/testing/mock-loader-service.h

fidl::ClientEnd<fuchsia_ldsvc::Loader> & client ()

Defined at line 65 of file ../../sdk/lib/ld/testing/include/lib/ld/testing/mock-loader-service.h

void MockLoaderService ()

Defined at line 81 of file ../../sdk/lib/ld/testing/mock-loader-service.cc

void ~MockLoaderService ()

Defined at line 83 of file ../../sdk/lib/ld/testing/mock-loader-service.cc

void Init ()

This must be called before other methods.

It should be used inside ASSERT_NO_FATAL_FAILURE(...).

Defined at line 85 of file ../../sdk/lib/ld/testing/mock-loader-service.cc

void ExpectLoadObject (std::string_view name, zx::result<zx::vmo> expected_result)

Tell the mock server to expect a LoadObject request for a VMO with `name`

and to return the `expected_result`.

Defined at line 92 of file ../../sdk/lib/ld/testing/mock-loader-service.cc

void ExpectConfig (std::string_view name, zx::result<> expected_result)

Tell the mock server to expect a Config request with `name` and to return

`expected_result`.

Defined at line 99 of file ../../sdk/lib/ld/testing/mock-loader-service.cc

Friends

class MockLoaderServiceForTest