Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Side by Side Diff: chrome/browser/chromeos/preferences_unittest.cc

Issue 9999018: chrome/browser/chromeos/input_method/ refactoring [part 6 of 6] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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
5 #include "chrome/browser/chromeos/preferences.h"
6
7 #include "chrome/browser/chromeos/input_method/mock_input_method_manager.h"
8 #include "chrome/browser/prefs/pref_member.h"
9 #include "chrome/common/pref_names.h"
10 #include "chrome/test/base/testing_pref_service.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace chromeos {
14 namespace {
15
16 class MyMockInputMethodManager : public input_method::MockInputMethodManager {
17 public:
18 MyMockInputMethodManager(StringPrefMember* previous,
19 StringPrefMember* current)
20 : previous_(previous),
21 current_(current) {
22 }
23 virtual ~MyMockInputMethodManager() {
24 }
25
26 virtual bool SetInputMethodConfig(
27 const std::string& section,
28 const std::string& config_name,
29 const input_method::InputMethodConfigValue& value) OVERRIDE {
30 // Assume the preload engines list is "KeyboardC,KeyboardA,KeyboardB".
31 // Switch to the first one, C.
32 ChangeInputMethod("KeyboardC");
33 return true;
34 }
35
36 virtual void ChangeInputMethod(const std::string& input_method_id) OVERRIDE {
37 last_input_method_id_ = input_method_id;
38 // Do the same thing as BrowserStateMonitor::UpdateUserPreferences.
39 const std::string current_input_method_on_pref = current_->GetValue();
40 if (current_input_method_on_pref == input_method_id)
41 return;
42 previous_->SetValue(current_input_method_on_pref);
43 current_->SetValue(input_method_id);
44 }
45
46 std::string last_input_method_id_;
47
48 private:
49 StringPrefMember* previous_;
50 StringPrefMember* current_;
51 };
52
53 } // anonymous namespace
54
55 TEST(PreferencesTest, TestUpdatePrefOnBrowserScreenDetails) {
56 TestingPrefService prefs;
57 Preferences::RegisterUserPrefs(&prefs);
58
59 StringPrefMember previous;
60 previous.Init(prefs::kLanguagePreviousInputMethod, &prefs, NULL);
61 previous.SetValue("KeyboardA");
62 StringPrefMember current;
63 current.Init(prefs::kLanguageCurrentInputMethod, &prefs, NULL);
64 current.SetValue("KeyboardB");
65
66 MyMockInputMethodManager mock_manager(&previous, &current);
67 Preferences testee(&mock_manager);
68 testee.InitUserPrefsForTesting(&prefs);
69 testee.SetInputMethodListForTesting();
70
71 // Confirm they're unchanged.
72 EXPECT_EQ("KeyboardA", previous.GetValue());
73 EXPECT_EQ("KeyboardB", current.GetValue());
74 EXPECT_EQ("KeyboardB", mock_manager.last_input_method_id_);
75 }
76
77 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.cc ('k') | chrome/browser/chromeos/system/ash_system_tray_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698