Skip to content

Commit

Permalink
ambient: Moved mock ambient backend model to a separate class
Browse files Browse the repository at this point in the history
Now the MockAmbientBackendModel has been de-duplicated and has now
been moved to a separate class.

Bug: b/271098375

Test: ./ash_unittests --gtest_filter=*Ambient*PhotoControllerTest*
Change-Id: Ied8d2e40eb5bcbef803a0c847a429174f9c599be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4300549
Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Fahad Mansoor <fahadmansoor@google.com>
Reviewed-by: Eric Sum <esum@google.com>
Cr-Commit-Position: refs/heads/main@{#1115623}
  • Loading branch information
Fahad Mansoor authored and Chromium LUCI CQ committed Mar 10, 2023
1 parent 201d425 commit 35f8dcf
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
2 changes: 2 additions & 0 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3721,6 +3721,8 @@ static_library("test_support") {
"ambient/test/ambient_topic_queue_test_delegate.h",
"ambient/test/fake_ambient_animation_static_resources.cc",
"ambient/test/fake_ambient_animation_static_resources.h",
"ambient/test/mock_ambient_backend_model_observer.cc",
"ambient/test/mock_ambient_backend_model_observer.h",
"ambient/test/mock_ambient_view_observer.cc",
"ambient/test/mock_ambient_view_observer.h",
"ambient/test/test_ambient_client.cc",
Expand Down
13 changes: 1 addition & 12 deletions ash/ambient/ambient_managed_photo_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "ash/ambient/model/ambient_photo_config.h"
#include "ash/ambient/model/ambient_slideshow_photo_config.h"
#include "ash/ambient/test/ambient_ash_test_base.h"
#include "ash/ambient/test/mock_ambient_backend_model_observer.h"
#include "ash/constants/ash_features.h"
#include "ash/public/cpp/ambient/proto/photo_cache_entry.pb.h"
#include "ash/public/cpp/test/in_process_image_decoder.h"
Expand All @@ -35,18 +36,6 @@ using ::testing::Not;

namespace {

// TODO (b/271098375): Move to a separate class from here and the photo
// controller unit tests
class MockAmbientBackendModelObserver : public AmbientBackendModelObserver {
public:
MockAmbientBackendModelObserver() = default;
~MockAmbientBackendModelObserver() override = default;

// AmbientBackendModelObserver:
MOCK_METHOD(void, OnImageAdded, (), (override));
MOCK_METHOD(void, OnImagesReady, (), (override));
};

bool AreBackedBySameImage(const PhotoWithDetails& topic_l,
const PhotoWithDetails& topic_r) {
return !topic_l.photo.isNull() && !topic_r.photo.isNull() &&
Expand Down
10 changes: 1 addition & 9 deletions ash/ambient/ambient_photo_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "ash/ambient/test/ambient_ash_test_base.h"
#include "ash/ambient/test/ambient_test_util.h"
#include "ash/ambient/test/ambient_topic_queue_test_delegate.h"
#include "ash/ambient/test/mock_ambient_backend_model_observer.h"
#include "ash/public/cpp/ambient/ambient_backend_controller.h"
#include "ash/public/cpp/ambient/fake_ambient_backend_controller_impl.h"
#include "ash/public/cpp/ambient/proto/photo_cache_entry.pb.h"
Expand Down Expand Up @@ -57,15 +58,6 @@ using ::testing::Pointwise;
using ::testing::SizeIs;

namespace {
class MockAmbientBackendModelObserver : public AmbientBackendModelObserver {
public:
MockAmbientBackendModelObserver() = default;
~MockAmbientBackendModelObserver() override = default;

// AmbientBackendModelObserver:
MOCK_METHOD(void, OnImageAdded, (), (override));
MOCK_METHOD(void, OnImagesReady, (), (override));
};

bool AreBackedBySameImage(const PhotoWithDetails& topic_l,
const PhotoWithDetails& topic_r) {
Expand Down
13 changes: 13 additions & 0 deletions ash/ambient/test/mock_ambient_backend_model_observer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/ambient/test/mock_ambient_backend_model_observer.h"

namespace ash {

MockAmbientBackendModelObserver::MockAmbientBackendModelObserver() = default;

MockAmbientBackendModelObserver::~MockAmbientBackendModelObserver() = default;

} // namespace ash
25 changes: 25 additions & 0 deletions ash/ambient/test/mock_ambient_backend_model_observer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_AMBIENT_TEST_MOCK_AMBIENT_BACKEND_MODEL_OBSERVER_H_
#define ASH_AMBIENT_TEST_MOCK_AMBIENT_BACKEND_MODEL_OBSERVER_H_

#include "ash/ambient/model/ambient_backend_model_observer.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace ash {

class MockAmbientBackendModelObserver : public AmbientBackendModelObserver {
public:
MockAmbientBackendModelObserver();
~MockAmbientBackendModelObserver() override;

// AmbientBackendModelObserver:
MOCK_METHOD(void, OnImageAdded, (), (override));
MOCK_METHOD(void, OnImagesReady, (), (override));
};

} // namespace ash

#endif // ASH_AMBIENT_TEST_MOCK_AMBIENT_BACKEND_MODEL_OBSERVER_H_

0 comments on commit 35f8dcf

Please sign in to comment.