OLD | NEW |
| (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 "base/strings/string_number_conversions.h" | |
6 #include "chrome/browser/extensions/app_notification_manager.h" | |
7 #include "chrome/browser/extensions/app_notification_test_util.h" | |
8 #include "chrome/common/extensions/extension.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 using base::IntToString; | |
12 using extensions::AppNotification; | |
13 using extensions::AppNotificationList; | |
14 | |
15 namespace app_notification_test_util { | |
16 | |
17 void ExpectListsEqual(const AppNotificationList& one, | |
18 const AppNotificationList& two) { | |
19 ASSERT_EQ(one.size(), two.size()); | |
20 for (size_t i = 0; i < one.size(); i++) { | |
21 ASSERT_TRUE(one[i]->Equals(*two[i])); | |
22 } | |
23 } | |
24 | |
25 void AddNotifications(AppNotificationList* list, | |
26 const std::string& extension_id, | |
27 int count, | |
28 const std::string& prefix) { | |
29 for (int i = 0; i < count; i++) { | |
30 std::string guid = prefix + "_guid_" + IntToString(i); | |
31 std::string title = prefix + "_title_" + IntToString(i); | |
32 std::string body = prefix + "_body_" + IntToString(i); | |
33 AppNotification* item = new AppNotification( | |
34 true, base::Time::Now(), guid, extension_id, title, body); | |
35 if (i % 2 == 0) { | |
36 item->set_link_url(GURL("http://www.example.com/" + prefix)); | |
37 item->set_link_text(prefix + "_link_" + IntToString(i)); | |
38 } | |
39 list->push_back(linked_ptr<AppNotification>(item)); | |
40 } | |
41 } | |
42 | |
43 bool AddCopiesFromList(extensions::AppNotificationManager* manager, | |
44 const AppNotificationList& list) { | |
45 bool result = true; | |
46 for (AppNotificationList::const_iterator i = list.begin(); | |
47 i != list.end(); | |
48 ++i) { | |
49 result = result && manager->Add((*i)->Copy()); | |
50 } | |
51 return result; | |
52 } | |
53 | |
54 } // namespace app_notification_test_util | |
OLD | NEW |