summaryrefslogtreecommitdiff
path: root/chromium/media/learning/common/media_learning_tasks_unittest.cc
blob: dc9d6547652b9746e3743ca37902a78528222efc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/learning/common/media_learning_tasks.h"

#include <memory>

#include "base/bind.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

using testing::_;

namespace media {
namespace learning {

class MediaLearningTasksTest : public testing::Test {};

TEST_F(MediaLearningTasksTest, WillPlayTask) {
  LearningTask task = MediaLearningTasks::Get(tasknames::kWillPlay);
  // Make sure the name is correct, mostly to reduce cut-and-paste errors.
  EXPECT_EQ(task.name, "MediaLearningWillPlay");
}

TEST_F(MediaLearningTasksTest, ConsecutiveBadWindowsTask) {
  LearningTask task =
      MediaLearningTasks::Get(tasknames::kConsecutiveBadWindows);
  // Make sure the name is correct, mostly to reduce cut-and-paste errors.
  EXPECT_EQ(task.name, "MediaLearningConsecutiveBadWindows");
}

TEST_F(MediaLearningTasksTest, ConsecutiveNNRsTask) {
  LearningTask task = MediaLearningTasks::Get(tasknames::kConsecutiveNNRs);
  // Make sure the name is correct, mostly to reduce cut-and-paste errors.
  EXPECT_EQ(task.name, "MediaLearningConsecutiveNNRs");
}

TEST_F(MediaLearningTasksTest, EnumeratesAllTasks) {
  int count = 0;
  auto cb = base::BindRepeating(
      [](int* count, const LearningTask& task) { (*count)++; },
      base::Unretained(&count));
  MediaLearningTasks::Register(std::move(cb));
  EXPECT_EQ(count, 3);
}

}  // namespace learning
}  // namespace media