| 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" |
| 17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 class MockObserver : public AvatarMenuModelObserver { | 24 class MockObserver : public AvatarMenuModelObserver { |
| 24 public: | 25 public: |
| 25 MockObserver() : count_(0) {} | 26 MockObserver() : count_(0) {} |
| 26 virtual ~MockObserver() {} | 27 virtual ~MockObserver() {} |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 // AvatarMenu and multiple profiles works after user logged in. | 49 // AvatarMenu and multiple profiles works after user logged in. |
| 49 manager_.SetLoggedIn(true); | 50 manager_.SetLoggedIn(true); |
| 50 #endif | 51 #endif |
| 51 } | 52 } |
| 52 | 53 |
| 53 Browser* browser() { return NULL; } | 54 Browser* browser() { return NULL; } |
| 54 | 55 |
| 55 TestingProfileManager* manager() { return &manager_; } | 56 TestingProfileManager* manager() { return &manager_; } |
| 56 | 57 |
| 57 private: | 58 private: |
| 59 content::TestBrowserThreadBundle thread_bundle_; |
| 58 TestingProfileManager manager_; | 60 TestingProfileManager manager_; |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 TEST_F(AvatarMenuModelTest, InitialCreation) { | 63 TEST_F(AvatarMenuModelTest, InitialCreation) { |
| 62 string16 name1(ASCIIToUTF16("Test 1")); | 64 string16 name1(ASCIIToUTF16("Test 1")); |
| 63 string16 name2(ASCIIToUTF16("Test 2")); | 65 string16 name2(ASCIIToUTF16("Test 2")); |
| 64 | 66 |
| 65 manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), | 67 manager()->CreateTestingProfile("p1", scoped_ptr<PrefServiceSyncable>(), |
| 66 name1, 0, std::string()); | 68 name1, 0, std::string()); |
| 67 manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), | 69 manager()->CreateTestingProfile("p2", scoped_ptr<PrefServiceSyncable>(), |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 base::string16 managed_user_label = | 258 base::string16 managed_user_label = |
| 257 l10n_util::GetStringUTF16(IDS_MANAGED_USER_AVATAR_LABEL); | 259 l10n_util::GetStringUTF16(IDS_MANAGED_USER_AVATAR_LABEL); |
| 258 const AvatarMenuModel::Item& item1 = model.GetItemAt(0); | 260 const AvatarMenuModel::Item& item1 = model.GetItemAt(0); |
| 259 EXPECT_NE(item1.sync_state, managed_user_label); | 261 EXPECT_NE(item1.sync_state, managed_user_label); |
| 260 | 262 |
| 261 const AvatarMenuModel::Item& item2 = model.GetItemAt(1); | 263 const AvatarMenuModel::Item& item2 = model.GetItemAt(1); |
| 262 EXPECT_EQ(item2.sync_state, managed_user_label); | 264 EXPECT_EQ(item2.sync_state, managed_user_label); |
| 263 } | 265 } |
| 264 | 266 |
| 265 } // namespace | 267 } // namespace |
| OLD | NEW |