chromium/components/services/app_service/public/cpp/app_registry_cache_unittest.cc

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/services/app_service/public/cpp/app_registry_cache.h"

#include <map>
#include <set>
#include <utility>
#include <vector>

#include "base/containers/contains.h"
#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
#include "components/services/app_service/public/cpp/app_types.h"
#include "components/services/app_service/public/cpp/features.h"
#include "components/services/app_service/public/cpp/types_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace apps {

namespace {

apps::AppPtr MakeApp(const char* app_id,
                     const char* name,
                     apps::AppType app_type = apps::AppType::kArc,
                     apps::Readiness readiness = apps::Readiness::kUnknown,
                     bool should_update_icon_version = false) {}

class MockRegistryObserver : public apps::AppRegistryCache::Observer {};

MATCHER_P(HasAppId, app_id, "Has the correct app id") {}

// RemoveObserver is used to test OnAppUpdate for the removed app.
class RemoveObserver : public apps::AppRegistryCache::Observer {};

// Responds to a cache's OnAppUpdate to call back into the cache, checking that
// the cache presents a self-consistent snapshot. For example, the app names
// should match for the outer and inner AppUpdate.
//
// In the tests below, just "recursive" means that cache.OnApps calls
// observer.OnAppsUpdate which calls cache.ForApp and cache.ForAllApps.
// "Super-recursive" means that cache.OnApps calls observer.OnAppsUpdate calls
// cache.OnApps which calls observer.OnAppsUpdate.
class RecursiveObserver : public AppRegistryCache::Observer {};

// InitializedObserver is used to test the OnAppTypeInitialized interface for
// AppRegistryCache::Observer.
class InitializedObserver : public apps::AppRegistryCache::Observer {};

}  // namespace

class AppRegistryCacheTest : public testing::Test,
                             public AppRegistryCache::Observer {};

TEST_F(AppRegistryCacheTest, OnApps) {}

TEST_F(AppRegistryCacheTest, Removed) {}

TEST_F(AppRegistryCacheTest, RemovedAndAdded) {}

TEST_F(AppRegistryCacheTest, RemovedAndAddMultipleApps) {}

TEST_F(AppRegistryCacheTest, Observer) {}

TEST_F(AppRegistryCacheTest, Recursive) {}

TEST_F(AppRegistryCacheTest, SuperRecursive) {}

// Verify the OnAppTypeInitialized callback when OnApps is called.
TEST_F(AppRegistryCacheTest, OnAppTypeInitializedWithUpdateFirst) {}

// Verify the OnAppTypeInitialized callback when OnApps is called for multiple
// App types.
TEST_F(AppRegistryCacheTest, OnAppTypeInitializedWithMultipleAppTypes) {}

// Verify the OnAppTypeInitialized callback when OnApps is called for empty apps
// vector.
TEST_F(AppRegistryCacheTest, OnAppTypeInitializedWithEmptyUpdate) {}

TEST_F(AppRegistryCacheTest, IsAppInstalledForInstalledApp) {}

TEST_F(AppRegistryCacheTest, IsAppInstalledForUninstalledApp) {}

TEST_F(AppRegistryCacheTest, OnAppUpdateCount) {}

}  // namespace apps