[M120 Migration][MM] Framerate calculation
[platform/framework/web/chromium-efl.git] / media / test / run_all_unittests.cc
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/functional/bind.h"
6 #include "base/test/launcher/unit_test_launcher.h"
7 #include "base/test/test_discardable_memory_allocator.h"
8 #include "base/test/test_suite.h"
9 #include "build/build_config.h"
10 #include "media/base/fake_localized_strings.h"
11 #include "media/base/media.h"
12 #include "media/base/media_switches.h"
13 #include "mojo/core/embedder/embedder.h"
14
15 #if BUILDFLAG(IS_ANDROID)
16 #include "media/base/android/media_codec_bridge_impl.h"
17 #include "media/base/android/media_codec_util.h"
18 #endif
19
20 #if BUILDFLAG(IS_CHROMEOS)
21 #include "ui/gfx/linux/gbm_util.h"  // nogncheck
22 #endif                              // BUILDFLAG(IS_CHROMEOS)
23
24 class TestSuiteNoAtExit : public base::TestSuite {
25  public:
26   TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {
27 #if BUILDFLAG(IS_CHROMEOS)
28     // TODO(b/271455200): the FeatureList has not been initialized by this
29     // point, so this call will always disable Intel media compression. We may
30     // want to move this to a later point to be able to run media unit tests
31     // with Intel media compression enabled.
32     ui::EnsureIntelMediaCompressionEnvVarIsSet();
33 #endif
34   }
35   ~TestSuiteNoAtExit() override = default;
36
37  protected:
38   void Initialize() override;
39
40  private:
41   base::TestDiscardableMemoryAllocator discardable_memory_allocator_;
42 };
43
44 void TestSuiteNoAtExit::Initialize() {
45   // Run TestSuite::Initialize first so that logging is initialized.
46   base::TestSuite::Initialize();
47
48 #if BUILDFLAG(IS_ANDROID)
49   media::MediaCodecBridgeImpl::SetupCallbackHandlerForTesting();
50 #endif
51
52   // Run this here instead of main() to ensure an AtExitManager is already
53   // present.
54   media::InitializeMediaLibrary();
55   media::SetUpFakeLocalizedStrings();
56
57   base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
58 }
59
60 int main(int argc, char** argv) {
61   mojo::core::Init();
62   TestSuiteNoAtExit test_suite(argc, argv);
63
64   return base::LaunchUnitTests(
65       argc, argv,
66       base::BindOnce(&TestSuiteNoAtExit::Run, base::Unretained(&test_suite)));
67 }