| Index: chrome/browser/notifications/message_center_settings_controller_unittest.cc
|
| diff --git a/chrome/browser/notifications/message_center_settings_controller_unittest.cc b/chrome/browser/notifications/message_center_settings_controller_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4f00409173872a6e7c7ae2118c42eb26cb1220a3
|
| --- /dev/null
|
| +++ b/chrome/browser/notifications/message_center_settings_controller_unittest.cc
|
| @@ -0,0 +1,85 @@
|
| +// 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.
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/browser/notifications/message_center_settings_controller.h"
|
| +#include "chrome/browser/prefs/pref_service_syncable.h"
|
| +#include "chrome/browser/profiles/profile_info_cache.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/test/base/testing_browser_process.h"
|
| +#include "chrome/test/base/testing_profile_manager.h"
|
| +#include "content/public/test/test_browser_thread_bundle.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +#include "ui/message_center/notifier_settings.h"
|
| +
|
| +class MessageCenterSettingsControllerTest : public testing::Test {
|
| + protected:
|
| + MessageCenterSettingsControllerTest()
|
| + : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {};
|
| + virtual ~MessageCenterSettingsControllerTest() {};
|
| +
|
| + base::FilePath GetProfilePath(const std::string& base_name) {
|
| + return testing_profile_manager_.profile_manager()->user_data_dir()
|
| + .AppendASCII(base_name);
|
| + }
|
| +
|
| + virtual void SetUp() OVERRIDE {
|
| + ASSERT_TRUE(testing_profile_manager_.SetUp());
|
| + }
|
| +
|
| + ProfileInfoCache* GetCache() {
|
| + return testing_profile_manager_.profile_info_cache();
|
| + }
|
| +
|
| + void ResetCache() { testing_profile_manager_.DeleteProfileInfoCache(); }
|
| +
|
| + void CreateProfile(const std::string& name, const string16& login_info) {
|
| + testing_profile_manager_.CreateTestingProfile(
|
| + name, scoped_ptr<PrefServiceSyncable>(), login_info, 0, false);
|
| + }
|
| +
|
| + TestingProfileManager testing_profile_manager_;
|
| +
|
| + private:
|
| + content::TestBrowserThreadBundle thread_bundle_;
|
| +};
|
| +
|
| +TEST_F(MessageCenterSettingsControllerTest, NotifierGroups) {
|
| + CreateProfile("Profile-1", UTF8ToUTF16("email@one.com"));
|
| + CreateProfile("Profile-2", UTF8ToUTF16("email@two.com"));
|
| +
|
| + scoped_ptr<MessageCenterSettingsController> controller(
|
| + new MessageCenterSettingsController(GetCache()));
|
| +
|
| + EXPECT_EQ(controller->GetNotifierGroupCount(), 2);
|
| +
|
| + EXPECT_EQ(controller->GetNotifierGroupAt(0).name, UTF8ToUTF16("Profile-1"));
|
| + EXPECT_EQ(controller->GetNotifierGroupAt(0).login_info,
|
| + UTF8ToUTF16("email@one.com"));
|
| + EXPECT_EQ(controller->GetNotifierGroupAt(0).index, 0);
|
| +
|
| + EXPECT_EQ(controller->GetNotifierGroupAt(1).name, UTF8ToUTF16("Profile-2"));
|
| + EXPECT_EQ(controller->GetNotifierGroupAt(1).login_info,
|
| + UTF8ToUTF16("email@two.com"));
|
| + EXPECT_EQ(controller->GetNotifierGroupAt(1).index, 1);
|
| +
|
| + EXPECT_EQ(controller->GetActiveNotifierGroup().name,
|
| + UTF8ToUTF16("Profile-1"));
|
| + EXPECT_EQ(controller->GetActiveNotifierGroup().login_info,
|
| + UTF8ToUTF16("email@one.com"));
|
| + EXPECT_EQ(controller->GetActiveNotifierGroup().index, 0);
|
| +
|
| + controller->SwitchToNotifierGroup(1);
|
| + EXPECT_EQ(controller->GetActiveNotifierGroup().name,
|
| + UTF8ToUTF16("Profile-2"));
|
| + EXPECT_EQ(controller->GetActiveNotifierGroup().login_info,
|
| + UTF8ToUTF16("email@two.com"));
|
| + EXPECT_EQ(controller->GetActiveNotifierGroup().index, 1);
|
| +
|
| + controller->SwitchToNotifierGroup(0);
|
| + EXPECT_EQ(controller->GetActiveNotifierGroup().name,
|
| + UTF8ToUTF16("Profile-1"));
|
| +}
|
|
|