chromium/components/optimization_guide/core/tflite_model_executor_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 "base/path_service.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/threading/thread_restrictions.h"
#include "components/optimization_guide/core/test_model_info_builder.h"
#include "components/optimization_guide/core/test_optimization_guide_model_provider.h"
#include "components/optimization_guide/core/test_tflite_model_executor.h"
#include "components/optimization_guide/core/test_tflite_model_handler.h"
#include "components/optimization_guide/machine_learning_tflite_buildflags.h"
#include "components/optimization_guide/proto/common_types.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/task_utils.h"

namespace optimization_guide {
namespace {

class NoUnloadingTestTFLiteModelHandler : public TestTFLiteModelHandler {};

class AlwaysInMemTestTFLiteModelHandler : public TestTFLiteModelHandler {};

class EnsureCancelledTestTFLiteModelExecutor : public TestTFLiteModelExecutor {};

class EnsureCancelledTestTFLiteModelHandler : public TestTFLiteModelHandler {};

class TFLiteModelExecutorTest : public testing::Test {};

TEST_F(TFLiteModelExecutorTest, ExecuteReturnsImmediatelyIfNoModelLoaded) {}

TEST_F(TFLiteModelExecutorTest, BatchExecuteReturnsImmediatelyIfNoModelLoaded) {}

TEST_F(TFLiteModelExecutorTest, ExecuteWithLoadedModel) {}

TEST_F(TFLiteModelExecutorTest, BatchExecuteWithLoadedModel) {}

TEST_F(TFLiteModelExecutorTest, BatchExecutionSyncWithLoadedModel) {}

TEST_F(TFLiteModelExecutorTest, BatchExecutionSyncNoModelLoaded) {}

TEST_F(TFLiteModelExecutorTest, ExecuteTwiceWithLoadedModel) {}

TEST_F(TFLiteModelExecutorTest, DoNotUnloadAfterExecution) {}

// TODO(b/283522287): Mediapipe does not support cancelling long-running tasks.
#if !BUILDFLAG(BUILD_WITH_MEDIAPIPE_LIB)
class CancelledTFLiteModelExecutorTest : public TFLiteModelExecutorTest {};

TEST_F(CancelledTFLiteModelExecutorTest, RunsTooLong) {}

TEST_F(CancelledTFLiteModelExecutorTest, BatchRunsTooLong) {}
#endif  // !BUILDFLAG(BUILD_WITH_MEDIAPIPE_LIB)

TEST_F(TFLiteModelExecutorTest, UpdateModelFileWithPreloading) {}

TEST_F(TFLiteModelExecutorTest, NullModelUpdate) {}

class ForegroundTFLiteModelExecutorTest : public TFLiteModelExecutorTest {};

// See https://crbug.com/1477407.
TEST_F(ForegroundTFLiteModelExecutorTest, LoadAndUpdateAndUnloadModel) {}

}  // namespace
}  // namespace optimization_guide