OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/profiles/avatar_menu_model.h" | 5 #include "chrome/browser/profiles/avatar_menu_model.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/prefs/pref_service_syncable.h" | 11 #include "chrome/browser/prefs/pref_service_syncable.h" |
12 #include "chrome/browser/profiles/avatar_menu_model_observer.h" | 12 #include "chrome/browser/profiles/avatar_menu_model_observer.h" |
13 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
14 #include "chrome/browser/profiles/profiles_state.h" | 14 #include "chrome/browser/profiles/profiles_state.h" |
15 #include "chrome/test/base/testing_browser_process.h" | 15 #include "chrome/test/base/testing_browser_process.h" |
16 #include "chrome/test/base/testing_profile_manager.h" | 16 #include "chrome/test/base/testing_profile_manager.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | |
18 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 class MockObserver : public AvatarMenuModelObserver { | 23 class MockObserver : public AvatarMenuModelObserver { |
25 public: | 24 public: |
26 MockObserver() : count_(0) {} | 25 MockObserver() : count_(0) {} |
27 virtual ~MockObserver() {} | 26 virtual ~MockObserver() {} |
(...skipping 21 matching lines...) Expand all Loading... |
49 // AvatarMenu and multiple profiles works after user logged in. | 48 // AvatarMenu and multiple profiles works after user logged in. |
50 manager_.SetLoggedIn(true); | 49 manager_.SetLoggedIn(true); |
51 #endif | 50 #endif |
52 } | 51 } |
53 | 52 |
54 Browser* browser() { return NULL; } | 53 Browser* browser() { return NULL; } |
55 | 54 |
56 TestingProfileManager* manager() { return &manager_; } | 55 TestingProfileManager* manager() { return &manager_; } |
57 | 56 |
58 private: | 57 private: |
59 content::TestBrowserThreadBundle thread_bundle_; | |
60 TestingProfileManager manager_; | 58 TestingProfileManager manager_; |
61 }; | 59 }; |
62 | 60 |
63 TEST_F(AvatarMenuModelTest, InitialCreation) { | 61 TEST_F(AvatarMenuModelTest, InitialCreation) { |
64 string16 name1(ASCIIToUTF16("Test 1")); | 62 string16 name1(ASCIIToUTF16("Test 1")); |
65 string16 name2(ASCIIToUTF16("Test 2")); | 63 string16 name2(ASCIIToUTF16("Test 2")); |
66 | 64 |
67 manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), | 65 manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), |
68 name1, 0, std::string()); | 66 name1, 0, std::string()); |
69 manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), | 67 manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 base::string16 managed_user_label = | 256 base::string16 managed_user_label = |
259 l10n_util::GetStringUTF16(IDS_MANAGED_USER_AVATAR_LABEL); | 257 l10n_util::GetStringUTF16(IDS_MANAGED_USER_AVATAR_LABEL); |
260 const AvatarMenuModel::Item& item1 = model.GetItemAt(0); | 258 const AvatarMenuModel::Item& item1 = model.GetItemAt(0); |
261 EXPECT_NE(item1.sync_state, managed_user_label); | 259 EXPECT_NE(item1.sync_state, managed_user_label); |
262 | 260 |
263 const AvatarMenuModel::Item& item2 = model.GetItemAt(1); | 261 const AvatarMenuModel::Item& item2 = model.GetItemAt(1); |
264 EXPECT_EQ(item2.sync_state, managed_user_label); | 262 EXPECT_EQ(item2.sync_state, managed_user_label); |
265 } | 263 } |
266 | 264 |
267 } // namespace | 265 } // namespace |
OLD | NEW |