[roll] Roll fuchsia [docs] Simplify driver unit testing docs

DriverTestFixture library makes it quite a bit easier to write driver unit tests.

Rewriting quick start to be a one-stop shop for writing unit tests using this library.

Removing tutorial and reference that cover lower level libraries.

We may decide to create a deep dive doc from these first versions, but for now, keeping it simple.

NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
 +class FixtureConfig final {
> + public:
> +  static constexpr bool kDriverOnForeground = true;
> +  static constexpr bool kAutoStartDriver = true;
> +  static constexpr bool kAutoStopDriver = true;
> +
> +  using DriverType = simple::SimpleDriver;
> +  using EnvironmentType = SimpleDriverTestEnvironment;
> +};
> -### Start background dispatcher
> +## Define environment type class
> -The driver dispatcher is set as a background dispatcher,
> -[Driver FIDL test, line 118](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#118):
> +The `EnvironmentType` must be an isolated class
> +that provides your driver’s custom dependencies.
> +It does not need to provide framework dependencies (except for `compat::DeviceServer`),
> +as the fixture does that already.
> +If no extra dependencies are needed, use `fdf_testing::MinimalEnvironment`
> +which provides a default `compat::DeviceServer`.
> -```cpp {:.devsite-disable-click-to-copy}
> -fdf::UnownedSynchronizedDispatcher env_dispatcher_ = runtime_.StartBackgroundDispatcher();
> -```
> -
> -### Create TestNode object
> -
> -The test node serves the `fdf::Node protocol` to the driver,
> -[Driver FIDL test, lines 127-128](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#127):
> +Putting these together, a basic test with the minimal environment will look something like:
> -async_patterns::TestDispatcherBound<fdf_testing::TestNode> node_server_{
> -    env_dispatcher(), std::in_place, std::string("root")};
> +#include <lib/driver/testing/cpp/fixtures/gtest_fixture.h>
> +
> +class FixtureConfig final {
> + public:
> +  static constexpr bool kDriverOnForeground = true;
> +  static constexpr bool kAutoStartDriver = true;
> +  static constexpr bool kAutoStopDriver = true;
> +
> +  using DriverType = MyDriverType;
> +  using EnvironmentType = fdf_testing::MinimalEnvironment;
> +};
> +
> +class MyFixture : public fdf_testing::DriverTestFixture<FixtureConfiguration> {};
> +
> +TEST_F(MyFixture, MyTest) {
> +  driver().DoSomething();
> +}
> -### Create TestEnvironment object
> -
> -The environment can serve both the Zircon and Driver transport based protocols
> -to the driver,
> -[Driver FIDL test, lines 131-132](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#131):
> -
> -```cpp
> -async_patterns::TestDispatcherBound<fdf_testing::TestEnvironment> test_environment_{
> -    env_dispatcher(), std::in_place};
> -```
> -
> -### Create custom FIDL server
> -
> -The custom FIDL server lives on the background environment dispatcher and has
> -to be wrapped in a dispatcher bound,
> -[Driver FIDL test, lines 121-124](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#121):
> -
> -```
> -{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc" region_tag="custom_server_classes" adjust_indentation="auto" %}
> -```
> -
> -### Get custom FIDL server handler
> -
> -Get the instance handler for the driver protocol,
> -[Driver FIDL test, lines 71-74](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#71):
> -
> -```
> -{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc" region_tag="get_server_handlers" adjust_indentation="auto" %}
> -```
> -
> -### Move custom FIDL server handler
> -
> -Move the instance handler into our driver's incoming namespace,
> -[Driver FIDL test, lines 76-87](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#76):
> -
> -```
> -{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc" region_tag="move_server_handlers" adjust_indentation="auto" %}
> -```
> -
> -### Call CreateStartArgsAndServe
> -
> -Create and serve the `start_args table`,
> -[Driver FIDL test, lines 59-60](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#59):
> -
> -```c++
> -zx::result start_args = node_server_.SyncCall(&fdf_testing::TestNode::CreateStartArgsAndServe);
> -ASSERT_EQ(ZX_OK, start_args.status_value());
> -```
> -
> -### Initialize test environment
> -
> -Initialize the test environment,
> -[Driver FIDL test, lines 65-68](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#65):
> -
> -```
> -{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc" region_tag="initialize_test_environment" adjust_indentation="auto" %}
> -```
> -
> -## Run tests
> -
> -### Add the driver under test
> -
> -Add the driver under test which will use the foreground dispatcher,
> -[Driver FIDL test, lines 167](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#167):
> -
> -```cpp
> -fdf_testing::DriverUnderTest<TestDriver> driver_;
> -```
> -
> -### Start driver
> -
> -Start the driver,
> -[Driver FIDL test, lines 237-238](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#237):
> -
> -```cpp
> -zx::result result = runtime().RunToCompletion(driver_.SyncCall(
> -  &fdf_testing::DriverUnderTest<TestDriver>::Start, std::move(start_args())));
> -```
> -
> -### Add tests
> -
> -Use the arrow operator on the `DriverUnderTest` to add tests for the driver.
> -The arrow operator gives access to the driver type
> -(specified in the `DriverUnderTest` template), for example,
> -[Driver FIDL test, lines 384-287](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#284):
> -
> -```cpp
> -driver().SyncCall([](fdf_testing::DriverUnderTest<TestDriver>* driver) {
> -  zx::result result = (*driver)->ServeDriverService();
> -  ASSERT_EQ(ZX_OK, result.status_value());
> -});
> -```
> -
> -### Call PrepareStop
> -
> -`PrepareStop` has to be called manually by tests,
> -[Driver FIDL test, line 159](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc#159):
> -
> -```cpp
> -zx::result result = runtime().RunToCompletion(driver_.PrepareStop());
> -```
> -
> -### Run unit tests
> +## Run unit tests
> +
> +## DriverTestFixture reference

Original patch:
 diff --git a/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md b/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md
old mode 100644
new mode 100644
--- a/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md
+++ b/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md
@@ -1,191 +1,75 @@
 # Driver unit testing quick start

-Once you are familiar with the Driver Framework v2 testing framework, follow
-this quick start to write a test for drivers that need to make synchronous FIDL
-(see
-[driver FIDL test code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc)).
-If your driver doesn't need to make synchronous FIDL calls, see the
-[driver base test](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_base_test.cc).
+Follow this quick start to write a driver unit test based on the
+[simple unit test code example](https://cs.ope
[[[Original patch trimmed due to size. Decoded string size: 11269. Decoded string SHA1: 1f222c375c7b3a1d9378f08e49d1e38080121b35.]]]

Result patch:
 diff --git a/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md b/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md
index 1be3baf..8f8ba18 100644
--- a/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md
+++ b/docs/development/sdk/driver-testing/driver-unit-testing-quick-start.md
@@ -1,191 +1,75 @@
 # Driver unit testing quick start

-Once you are familiar with the Driver Framework v2 testing framework, follow
-this quick start to write a test for drivers that need to make synchronous FIDL
-(see
-[driver FIDL test code](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_fidl_test.cc)).
-If your driver doesn't need to make synchronous FIDL calls, see the
-[driver base test](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/sdk/lib/driver/component/cpp/tests/driver_base_test.cc).
+Follow this quick start to write a driver unit test based on the
+[simple unit test code example](https://cs.opens
[[[Result patch trimmed due to size. Decoded string size: 11278. Decoded string SHA1: 4cff81aec4a85cda6b39b675b41c4dd9a4943907.]]]

Original-Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1024312
Original-Revision: 77497c5fb4d0fe2f028f8748c66d98d782c5ad8d
GitOrigin-RevId: 12ca202650f4b777b2b0f83d1e9bcf26e25f2268
Change-Id: Id7042d9cd432eeac16af3c706a4116d719e4cfce
1 file changed
tree: cedcf3f78f077daca48fb45a8dd69c2897562b79
  1. ctf/
  2. git-hooks/
  3. infra/
  4. third_party/
  5. cts
  6. firmware
  7. flower
  8. jiri.lock
  9. MILESTONE
  10. minimal
  11. prebuilts
  12. README.md
  13. stem
  14. test_durations
  15. toolchain
README.md

Integration

This repository contains Fuchsia's Global Integration manifest files.

Making changes

All changes should be made to the internal version of this repository. Our infrastructure automatically updates this version when the internal one changes.

Currently all changes must be made by a Google employee. Non-Google employees wishing to make a change can ask for assistance via the IRC channel #fuchsia on Freenode.

Obtaining the source

First install Jiri.

Next run:

$ jiri init
$ jiri import minimal https://fuchsia.googlesource.com/integration
$ jiri update

Third party

Third party projects should have their own subdirectory in ./third_party.