summaryrefslogtreecommitdiffstats
path: root/chrome/test/base/scoped_testing_local_state.h
blob: 033075396f544c3ca71576481a614ff65d15e408 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_BASE_SCOPED_TESTING_LOCAL_STATE_H_
#define CHROME_TEST_BASE_SCOPED_TESTING_LOCAL_STATE_H_

#include "base/basictypes.h"
#include "base/prefs/testing_pref_service.h"

class TestingBrowserProcess;

// Helper class to temporarily set up a |local_state| in the global
// TestingBrowserProcess (for most unit tests it's NULL).
class ScopedTestingLocalState {
 public:
  explicit ScopedTestingLocalState(TestingBrowserProcess* browser_process);
  ~ScopedTestingLocalState();

  TestingPrefServiceSimple* Get() {
    return &local_state_;
  }

 private:
  TestingBrowserProcess* browser_process_;
  TestingPrefServiceSimple local_state_;

  DISALLOW_COPY_AND_ASSIGN(ScopedTestingLocalState);
};

#endif  // CHROME_TEST_BASE_SCOPED_TESTING_LOCAL_STATE_H_