1 // Copyright 2015 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.
5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/prefs/pref_service.h"
8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/settings_private/settings_private_delegate.h"
10 #include "chrome/browser/extensions/api/settings_private/settings_private_delegate_factory.h"
11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/common/extensions/api/settings_private.h"
13 #include "components/keyed_service/core/keyed_service.h"
14 #include "content/public/test/test_utils.h"
15 #include "extensions/common/switches.h"
17 #if defined(OS_CHROMEOS)
18 #include "chromeos/chromeos_switches.h"
21 namespace extensions
{
25 class SettingsPrivateApiTest
: public ExtensionApiTest
{
27 SettingsPrivateApiTest() {}
28 ~SettingsPrivateApiTest() override
{}
30 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
31 ExtensionApiTest::SetUpCommandLine(command_line
);
32 #if defined(OS_CHROMEOS)
33 command_line
->AppendSwitch(chromeos::switches::kStubCrosSettings
);
38 bool RunSettingsSubtest(const std::string
& subtest
) {
39 return RunExtensionSubtest("settings_private",
40 "main.html?" + subtest
,
41 kFlagLoadAsComponent
);
45 DISALLOW_COPY_AND_ASSIGN(SettingsPrivateApiTest
);
51 IN_PROC_BROWSER_TEST_F(SettingsPrivateApiTest
, SetPref
) {
52 EXPECT_TRUE(RunSettingsSubtest("setPref")) << message_
;
55 IN_PROC_BROWSER_TEST_F(SettingsPrivateApiTest
, GetPref
) {
56 EXPECT_TRUE(RunSettingsSubtest("getPref")) << message_
;
59 IN_PROC_BROWSER_TEST_F(SettingsPrivateApiTest
, GetAllPrefs
) {
60 EXPECT_TRUE(RunSettingsSubtest("getAllPrefs")) << message_
;
63 IN_PROC_BROWSER_TEST_F(SettingsPrivateApiTest
, OnPrefsChanged
) {
64 EXPECT_TRUE(RunSettingsSubtest("onPrefsChanged")) << message_
;
67 #if defined(OS_CHROMEOS)
68 IN_PROC_BROWSER_TEST_F(SettingsPrivateApiTest
, GetPref_CrOSSetting
) {
69 EXPECT_TRUE(RunSettingsSubtest("getPref_CrOSSetting")) << message_
;
72 IN_PROC_BROWSER_TEST_F(SettingsPrivateApiTest
, SetPref_CrOSSetting
) {
73 EXPECT_TRUE(RunSettingsSubtest("setPref_CrOSSetting")) << message_
;
76 IN_PROC_BROWSER_TEST_F(SettingsPrivateApiTest
, OnPrefsChanged_CrOSSetting
) {
77 EXPECT_TRUE(RunSettingsSubtest("onPrefsChanged_CrOSSetting")) << message_
;
81 } // namespace extensions