class RemoteAPITest
Defined at line 34 of file ../../src/developer/debug/zxdb/client/remote_api_test.h
This is a test harness for client tests that mock out the RemoteAPI. This class sets up a message
loop and the necessary plumbing.
The individual tests supply their own implementation of RemoteAPI.
Public Methods
void SetUp ()
testing::Test implementation.
Defined at line 25 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
void TearDown ()
Defined at line 29 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
void InjectModule (Process * process, fxl::RefPtr<ModuleSymbols> mod_sym, const std::string & name, uint64_t load_address, const std::string & build_id)
Injects the given module into the process. Most callers will want InjectMockModule() below.
Defined at line 31 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
Session & session ()
TODO(dangyi): Use pointer instead of reference to maintain consistency with ClientObject.
Defined at line 41 of file ../../src/developer/debug/zxdb/client/remote_api_test.h
MockRemoteAPI * mock_remote_api ()
Returns the MockRemoteAPI constructed by the default implementation of GetRemoteAPIImpl()
below.
Subclasses can provide any remote API implementation, but most tests want to use the standard
MockRemoteAPI. When GetRemoteAPIImpl() has not been overridden, it will create a MockRemoteAPI
and this getter will return it.
If a derived implementation overrides GetRemoteAPIImpl(), this will return null. Such tests
should provide their own getter for their specific implementation.
Defined at line 52 of file ../../src/developer/debug/zxdb/client/remote_api_test.h
fxl::RefPtr<MockModuleSymbols> InjectMockModule (Process * process, uint64_t load_address, const std::string & build_id, bool loaded)
Creates a MockModuleSymbols with a random name and build ID and reports it as loaded at the
given address. If the load address is 0, an arbitrary one will be generated. Similarly, a
build_id string may be given, an arbitrary one will be generated if not provided.
Defined at line 62 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
Process * InjectProcess (uint64_t process_koid)
Makes the target have a fake running process with the given KOID. The process has a
deterministic name, "process-" followed by the given koid in hex.
Defined at line 95 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
Process * InjectProcessWithModule (uint64_t process_koid, uint64_t load_address)
Calls |InjectProcess| with the given koid and then injects a mock module with
|InjectMockModule|. This is a convenience method for tests that don't inject their own modules,
but still need some module to be loaded to properly test notification and event paths. The
resume count in |mock_remote_api| is reset at the end of this method.
Defined at line 105 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
Thread * InjectThread (uint64_t process_koid, uint64_t thread_koid)
Sends a "thread created" notifications to the client for the given fake KOID. The thread will
be reported as running.
Defined at line 117 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
void InjectException (const debug_ipc::NotifyException & exception)
Sends the exception notification to the session.
Defined at line 127 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
void InjectExceptionWithStack (const debug_ipc::NotifyException & exception, std::vector<std::unique_ptr<Frame>> frames, bool has_all_frames)
Sends the exception notification and forces the given stack information. This bypasses the
normal thread metadata computation. The exception address will be taken from the address of the
top of the stack.
If you use the one that takes a NotifyException, the calling code need not populate the thread
vector and stack amount, they will be ignored.
Defined at line 141 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
void InjectExceptionWithStack (uint64_t process_koid, uint64_t thread_koid, debug_ipc::ExceptionType exception_type, std::vector<std::unique_ptr<Frame>> frames, bool has_all_frames, const std::vector<debug_ipc::BreakpointStats> & breakpoints)
Defined at line 176 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc
Protected Methods
debug::Arch GetArch ()
Allows tests to override the architecture for the test to run in. Defaults to x64/Fuchsia.
Defined at line 107 of file ../../src/developer/debug/zxdb/client/remote_api_test.h
debug::Platform GetPlatform ()
Defined at line 108 of file ../../src/developer/debug/zxdb/client/remote_api_test.h
std::unique_ptr<RemoteAPI> GetRemoteAPIImpl ()
Constructs the remote API implementation for this test.
Derived classes can override this to provide their own IPC mocks. Ownership will be transferred
to the Session so it will be valid until TearDown (most implementations will want to keep a
pointer).
The default implementation will construct a MockRemoteAPI which will be available from
mock_remote_api();
Defined at line 190 of file ../../src/developer/debug/zxdb/client/remote_api_test.cc