Skip to content

Commit

Permalink
Enable configuring testing input parameters.
Browse files Browse the repository at this point in the history
Major refactor of unittests to allow for configuring various inputs when
testing the DeviceActivityClient. Alongside this refactoring, test
coverage will also be drastically improved. Subsequent CLs will
refactor the unit tests and increase test coverage.

BUG=chromium:1390837

Change-Id: Id931cb7fa0ddf644335d09f3676b7a2aecc70f4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4026951
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Hirthanan Subenderan <hirthanan@google.com>
Cr-Commit-Position: refs/heads/main@{#1076669}
  • Loading branch information
Hirthanan Subenderan authored and Chromium LUCI CQ committed Nov 29, 2022
1 parent a266013 commit 0488a1b
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 217 deletions.
7 changes: 6 additions & 1 deletion chromeos/ash/components/device_activity/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ source_set("unit_tests") {
"//third_party/private_membership:private_membership",
]

data = [ "//third_party/private_membership/src/internal/testing/regression_test_data/test_data.binarypb" ]
data = [
"//chromeos/ash/components/device_activity/testing/private_computing_service_test_data.binarypb",

# TODO(crbug/1393862): Script should binarypb from textpb.
"//third_party/private_membership/src/internal/testing/regression_test_data/test_data.binarypb",
]
}

proto_library("fresnel_service_proto") {
Expand Down
33 changes: 33 additions & 0 deletions chromeos/ash/components/device_activity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,36 @@ generates a fingerprint using a high entropy seed which is sent to the Google
servers at most once. These are used to determine the device active counts.

Googlers: See go/chromeos-data-pc


## Testing

If you would like to update the private_computing_service_test_data.binarypb
protobuf representing the PrivateComputingClientRegressionTestData (used in unit testing),
you can add new test cases to private_computing_service_test_data.textpb.

You may then generate a new binarypb using the updated textpb.

```
cd ../chromium/src/chromeos/ash/components/device_activity/testing/
# Command used to convert between proto types (i.e textproto to binarypb)
# gqui from textproto:<path_to_textpb> <path_to_proto_message> --outfile=rawproto:<path_to_binarypb_destination>
gqui from textproto:private_computing_service_test_data.textpb proto \
~/chromiumos/src/platform2/system_api/dbus/private_computing/private_computing_service.proto:private_computing.PrivateComputingClientRegressionTestData \
--outfile=rawproto:private_computing_service_test_data.binarypb
```

After it has been successfully generated, make sure you update the unit tests.
You can then upload the new textpb and binarypb to Gerrit.


```
# Build the chromeos unittests target.
autoninja -C out/Default chromeos_unittests
# Run the device_activity/ unit tests.
./out/Default/chromeos_unittests --log-level=0 --enable-logging=stderr \
--gtest_filter="*DeviceActi*:*UseCase*"
```

Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_DEVICE_ACTIVITY)

State GetState() const;

// Used for testing.
std::vector<DeviceActiveUseCase*> GetUseCases() const;

DeviceActiveUseCase* GetUseCasePtr(
Expand Down

0 comments on commit 0488a1b

Please sign in to comment.