Skip to content

Commit

Permalink
Save and Recall: Add unittest for DeskModelWrapper
Browse files Browse the repository at this point in the history
This CL adds unittests for DeskModelWrapper. It also fixes a bug for
finding an admin template uuid that was found during unit testing.

BUG=1323946
TEST= DeskModelWrapperTest*

Change-Id: I40310a062f69bc293121cdfaba0dcb59fbaeccfb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3643038
Commit-Queue: Matthew Zhu <zhumatthew@google.com>
Reviewed-by: Yanzhu Du <yzd@google.com>
Cr-Commit-Position: refs/heads/main@{#1002402}
  • Loading branch information
zhumatthew authored and Chromium LUCI CQ committed May 11, 2022
1 parent 3162406 commit 21bf9c5
Show file tree
Hide file tree
Showing 4 changed files with 773 additions and 2 deletions.
1 change: 1 addition & 0 deletions components/desks_storage/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static_library("desks_storage") {
source_set("unit_tests") {
testonly = true
sources = [
"core/desk_model_wrapper_unittests.cc",
"core/desk_sync_bridge_unittest.cc",
"core/desk_template_conversion_unittests.cc",
"core/desk_template_util_unittests.cc",
Expand Down
9 changes: 9 additions & 0 deletions components/desks_storage/core/desk_model_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ void DeskModelWrapper::GetAllEntries(
void DeskModelWrapper::GetEntryByUUID(
const std::string& uuid,
DeskModel::GetEntryByUuidCallback callback) {
// Check if this is an admin template uuid first.
std::unique_ptr<ash::DeskTemplate> policy_entry =
GetAdminDeskTemplateByUUID(uuid);

if (policy_entry) {
std::move(callback).Run(GetEntryByUuidStatus::kOk, std::move(policy_entry));
return;
}

if (GetDeskTemplateModel()->HasUuid(uuid)) {
GetDeskTemplateModel()->GetEntryByUUID(uuid, std::move(callback));
} else {
Expand Down

0 comments on commit 21bf9c5

Please sign in to comment.