| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "ui/message_center/fake_message_center_tray_delegate.h" | 36 #include "ui/message_center/fake_message_center_tray_delegate.h" |
| 37 #include "ui/message_center/message_center.h" | 37 #include "ui/message_center/message_center.h" |
| 38 #include "ui/message_center/message_center_observer.h" | 38 #include "ui/message_center/message_center_observer.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 class BackgroundContentsServiceTest : public testing::Test { | 41 class BackgroundContentsServiceTest : public testing::Test { |
| 42 public: | 42 public: |
| 43 BackgroundContentsServiceTest() {} | 43 BackgroundContentsServiceTest() {} |
| 44 ~BackgroundContentsServiceTest() override {} | 44 ~BackgroundContentsServiceTest() override {} |
| 45 void SetUp() override { | 45 void SetUp() override { |
| 46 command_line_.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 46 command_line_.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 const base::DictionaryValue* GetPrefs(Profile* profile) { | 49 const base::DictionaryValue* GetPrefs(Profile* profile) { |
| 50 return profile->GetPrefs()->GetDictionary( | 50 return profile->GetPrefs()->GetDictionary( |
| 51 prefs::kRegisteredBackgroundContents); | 51 prefs::kRegisteredBackgroundContents); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Returns the stored pref URL for the passed app id. | 54 // Returns the stored pref URL for the passed app id. |
| 55 std::string GetPrefURLForApp(Profile* profile, const base::string16& appid) { | 55 std::string GetPrefURLForApp(Profile* profile, const base::string16& appid) { |
| 56 const base::DictionaryValue* pref = GetPrefs(profile); | 56 const base::DictionaryValue* pref = GetPrefs(profile); |
| 57 EXPECT_TRUE(pref->HasKey(base::UTF16ToUTF8(appid))); | 57 EXPECT_TRUE(pref->HasKey(base::UTF16ToUTF8(appid))); |
| 58 const base::DictionaryValue* value; | 58 const base::DictionaryValue* value; |
| 59 pref->GetDictionaryWithoutPathExpansion(base::UTF16ToUTF8(appid), &value); | 59 pref->GetDictionaryWithoutPathExpansion(base::UTF16ToUTF8(appid), &value); |
| 60 std::string url; | 60 std::string url; |
| 61 value->GetString("url", &url); | 61 value->GetString("url", &url); |
| 62 return url; | 62 return url; |
| 63 } | 63 } |
| 64 | 64 |
| 65 scoped_ptr<CommandLine> command_line_; | 65 scoped_ptr<base::CommandLine> command_line_; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class MockBackgroundContents : public BackgroundContents { | 68 class MockBackgroundContents : public BackgroundContents { |
| 69 public: | 69 public: |
| 70 explicit MockBackgroundContents(Profile* profile) | 70 explicit MockBackgroundContents(Profile* profile) |
| 71 : appid_(base::ASCIIToUTF16("app_id")), | 71 : appid_(base::ASCIIToUTF16("app_id")), |
| 72 profile_(profile) { | 72 profile_(profile) { |
| 73 } | 73 } |
| 74 MockBackgroundContents(Profile* profile, const std::string& id) | 74 MockBackgroundContents(Profile* profile, const std::string& id) |
| 75 : appid_(base::ASCIIToUTF16(id)), | 75 : appid_(base::ASCIIToUTF16(id)), |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 CreateCrashNotification(extension); | 385 CreateCrashNotification(extension); |
| 386 CreateCrashNotification(extension); | 386 CreateCrashNotification(extension); |
| 387 | 387 |
| 388 message_center::MessageCenter* message_center = | 388 message_center::MessageCenter* message_center = |
| 389 message_center::MessageCenter::Get(); | 389 message_center::MessageCenter::Get(); |
| 390 message_center::NotificationList::Notifications notifications = | 390 message_center::NotificationList::Notifications notifications = |
| 391 message_center->GetVisibleNotifications(); | 391 message_center->GetVisibleNotifications(); |
| 392 ASSERT_EQ(1u, notifications.size()); | 392 ASSERT_EQ(1u, notifications.size()); |
| 393 } | 393 } |
| 394 #endif | 394 #endif |
| OLD | NEW |