1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/tests/gtest/TestGfxPrefs.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "gtest/gtest.h" 1.10 + 1.11 +#include "gfxPrefs.h" 1.12 +#ifdef GFX_DECL_PREF 1.13 +#error "This is not supposed to be defined outside of gfxPrefs.h" 1.14 +#endif 1.15 + 1.16 +// If the default values for any of these preferences change, 1.17 +// just modify the test to match. We are only testing against 1.18 +// a particular value to make sure we receive the correct 1.19 +// result through this API. 1.20 + 1.21 +TEST(GfxPrefs, Singleton) { 1.22 + ASSERT_FALSE(gfxPrefs::SingletonExists()); 1.23 + gfxPrefs::GetSingleton(); 1.24 + ASSERT_TRUE(gfxPrefs::SingletonExists()); 1.25 + gfxPrefs::DestroySingleton(); 1.26 + ASSERT_FALSE(gfxPrefs::SingletonExists()); 1.27 +} 1.28 + 1.29 +TEST(GfxPrefs, LiveValues) { 1.30 + ASSERT_FALSE(gfxPrefs::SingletonExists()); 1.31 + gfxPrefs::GetSingleton(); 1.32 + ASSERT_TRUE(gfxPrefs::SingletonExists()); 1.33 + 1.34 + // Live boolean, default false 1.35 + ASSERT_FALSE(gfxPrefs::CanvasAzureAccelerated()); 1.36 + 1.37 + // Live int32_t, default 23456 1.38 + ASSERT_TRUE(gfxPrefs::LayerScopePort() == 23456); 1.39 + 1.40 + // Live uint32_t, default 2 1.41 + ASSERT_TRUE(gfxPrefs::MSAALevel() == 2); 1.42 + 1.43 + gfxPrefs::DestroySingleton(); 1.44 + ASSERT_FALSE(gfxPrefs::SingletonExists()); 1.45 +} 1.46 + 1.47 +TEST(GfxPrefs, OnceValues) { 1.48 + ASSERT_FALSE(gfxPrefs::SingletonExists()); 1.49 + gfxPrefs::GetSingleton(); 1.50 + ASSERT_TRUE(gfxPrefs::SingletonExists()); 1.51 + 1.52 + // Once boolean, default true 1.53 + ASSERT_TRUE(gfxPrefs::WorkAroundDriverBugs()); 1.54 + 1.55 + // Once boolean, default false 1.56 + ASSERT_FALSE(gfxPrefs::LayersDump()); 1.57 + 1.58 + // Once int32_t, default 95 1.59 + ASSERT_TRUE(gfxPrefs::CanvasSkiaGLCacheSize() == 96); 1.60 + 1.61 + // Once uint32_t, default 5 1.62 + ASSERT_TRUE(gfxPrefs::APZMaxVelocityQueueSize() == 5); 1.63 + 1.64 + // Once float, default -1 (should be OK with ==) 1.65 + ASSERT_TRUE(gfxPrefs::APZMaxVelocity() == -1.0f); 1.66 + 1.67 + gfxPrefs::DestroySingleton(); 1.68 + ASSERT_FALSE(gfxPrefs::SingletonExists()); 1.69 +} 1.70 +