gpu_info_unittest.cc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Copyright (c) 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "gpu/config/gpu_info.h"
  5. #include "testing/gtest/include/gtest/gtest.h"
  6. namespace gpu {
  7. namespace {
  8. // This overrides the base class to test behaviors of virtual functions.
  9. class TestGPUInfoEnumerator : public gpu::GPUInfo::Enumerator {
  10. public:
  11. TestGPUInfoEnumerator()
  12. : gpu_device_active_(false),
  13. video_decode_accelerator_profile_active_(false),
  14. video_encode_accelerator_profile_active_(false),
  15. image_decode_accelerator_profile_active_(false),
  16. overlay_info_active_(false),
  17. aux_attributes_active_(false) {}
  18. void AddInt64(const char* name, int64_t value) override {}
  19. void AddInt(const char* name, int value) override {}
  20. void AddString(const char* name, const std::string& value) override {}
  21. void AddBool(const char* name, bool value) override {}
  22. void AddBinary(const char* name,
  23. const base::span<const uint8_t>& blob) override {}
  24. void AddTimeDeltaInSecondsF(const char* name,
  25. const base::TimeDelta& value) override {}
  26. // Enumerator state mutator functions
  27. void BeginGPUDevice() override { gpu_device_active_ = true; }
  28. void EndGPUDevice() override { gpu_device_active_ = false; }
  29. void BeginVideoDecodeAcceleratorSupportedProfile() override {
  30. video_decode_accelerator_profile_active_ = true;
  31. }
  32. void EndVideoDecodeAcceleratorSupportedProfile() override {
  33. video_decode_accelerator_profile_active_ = false;
  34. }
  35. void BeginVideoEncodeAcceleratorSupportedProfile() override {
  36. video_encode_accelerator_profile_active_ = true;
  37. }
  38. void EndVideoEncodeAcceleratorSupportedProfile() override {
  39. video_encode_accelerator_profile_active_ = false;
  40. }
  41. void BeginImageDecodeAcceleratorSupportedProfile() override {
  42. image_decode_accelerator_profile_active_ = true;
  43. }
  44. void EndImageDecodeAcceleratorSupportedProfile() override {
  45. image_decode_accelerator_profile_active_ = false;
  46. }
  47. void BeginOverlayInfo() override { overlay_info_active_ = true; }
  48. void EndOverlayInfo() override { overlay_info_active_ = false; }
  49. void BeginAuxAttributes() override { aux_attributes_active_ = true; }
  50. void EndAuxAttributes() override { aux_attributes_active_ = false; }
  51. // Accessor functions
  52. bool gpu_device_active() const { return gpu_device_active_; }
  53. bool video_decode_accelerator_profile_active() const {
  54. return video_decode_accelerator_profile_active_;
  55. }
  56. bool video_encode_accelerator_profile_active() const {
  57. return video_encode_accelerator_profile_active_;
  58. }
  59. bool image_decode_accelerator_profile_active() const {
  60. return image_decode_accelerator_profile_active_;
  61. }
  62. bool aux_attributes_active() const { return aux_attributes_active_; }
  63. private:
  64. bool gpu_device_active_;
  65. bool video_decode_accelerator_profile_active_;
  66. bool video_encode_accelerator_profile_active_;
  67. bool image_decode_accelerator_profile_active_;
  68. bool overlay_info_active_;
  69. bool aux_attributes_active_;
  70. };
  71. } // namespace
  72. // Makes sure that after EnumerateFields is called, the field edit states
  73. // are inactive
  74. TEST(GpuInfoTest, FieldEditStates) {
  75. GPUInfo gpu_info;
  76. TestGPUInfoEnumerator enumerator;
  77. gpu_info.EnumerateFields(&enumerator);
  78. EXPECT_FALSE(enumerator.gpu_device_active());
  79. EXPECT_FALSE(enumerator.video_decode_accelerator_profile_active());
  80. EXPECT_FALSE(enumerator.video_encode_accelerator_profile_active());
  81. EXPECT_FALSE(enumerator.image_decode_accelerator_profile_active());
  82. EXPECT_FALSE(enumerator.aux_attributes_active());
  83. }
  84. } // namespace gpu