gfx/tests/gtest/TestGfxPrefs.cpp
author Jean-Yves Avenard <jyavenard@mozilla.com>
Thu, 06 Aug 2015 10:58:35 +1000
changeset 256477 c32cd64adb3745e4bfb5c44739c2417e1ff845fc
parent 255292 1b6d4b77f3a047568a3b17281278eb29162b4a70
child 284741 b7ee67cdf537e181473f0340402a09acadbb17b5
permissions -rw-r--r--
Bug 1190258: P1. Use getter to access MediaRawData mData and mSize member. r=cpearce

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "gtest/gtest.h"

#include "gfxPrefs.h"
#ifdef GFX_DECL_PREF
#error "This is not supposed to be defined outside of gfxPrefs.h"
#endif

// If the default values for any of these preferences change,
// just modify the test to match. We are only testing against
// a particular value to make sure we receive the correct
// result through this API.

TEST(GfxPrefs, Singleton) {
  gfxPrefs::GetSingleton();
  ASSERT_TRUE(gfxPrefs::SingletonExists());
}

TEST(GfxPrefs, LiveValues) {
  gfxPrefs::GetSingleton();
  ASSERT_TRUE(gfxPrefs::SingletonExists());

  // Live boolean, default false
  ASSERT_FALSE(gfxPrefs::LayersDumpTexture());

  // Live int32_t, default 23456
  ASSERT_TRUE(gfxPrefs::LayerScopePort() == 23456);

  // Live uint32_t, default 2
  ASSERT_TRUE(gfxPrefs::MSAALevel() == 2);
}

TEST(GfxPrefs, OnceValues) {
  gfxPrefs::GetSingleton();
  ASSERT_TRUE(gfxPrefs::SingletonExists());

  // Once boolean, default true
  ASSERT_TRUE(gfxPrefs::WorkAroundDriverBugs());

  // Once boolean, default false
  ASSERT_FALSE(gfxPrefs::LayersDump());

  // Once int32_t, default 95
  ASSERT_TRUE(gfxPrefs::CanvasSkiaGLCacheSize() == 96);

  // Once uint32_t, default 5
  ASSERT_TRUE(gfxPrefs::APZMaxVelocityQueueSize() == 5);

  // Once float, default -1 (should be OK with ==)
  ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f);
}

TEST(GfxPrefs, Set) {
  gfxPrefs::GetSingleton();
  ASSERT_TRUE(gfxPrefs::SingletonExists());

  // Once boolean, default false
  ASSERT_FALSE(gfxPrefs::LayersDump());
  gfxPrefs::SetLayersDump(true);
  ASSERT_TRUE(gfxPrefs::LayersDump());
  gfxPrefs::SetLayersDump(false);
  ASSERT_FALSE(gfxPrefs::LayersDump());

  // Live boolean, default false
  ASSERT_FALSE(gfxPrefs::LayersDumpTexture());
  gfxPrefs::SetLayersDumpTexture(true);
  ASSERT_TRUE(gfxPrefs::LayersDumpTexture());
  gfxPrefs::SetLayersDumpTexture(false);
  ASSERT_FALSE(gfxPrefs::LayersDumpTexture());

  // Once float, default -1
  ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f);
  gfxPrefs::SetAPZMaxVelocity(1.75f);
  ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == 1.75f);
  gfxPrefs::SetAPZMaxVelocity(-1.0f);
  ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f);
}