Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / notifications / sync_notifier / sync_notifier_test_utils.cc
blob23a11dcdb7be01dee7b4f13e8eeea266849c9e64
1 // Copyright 2013 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.
5 #include "chrome/browser/notifications/sync_notifier/sync_notifier_test_utils.h"
7 // Fake data for creating a SyncData object to use in creating a
8 // SyncedNotification.
9 const char kAppId1[] = "fboilmbenheemaomgaeehigklolhkhnf";
10 const char kAppId2[] = "fbcmoldooppoahjhfflnmljoanccekpf";
11 const char kAppId3[] = "fbcmoldooppoahjhfflnmljoanccek33";
12 const char kAppId4[] = "fbcmoldooppoahjhfflnmljoanccek44";
13 const char kAppId5[] = "fbcmoldooppoahjhfflnmljoanccek55";
14 const char kAppId6[] = "fbcmoldooppoahjhfflnmljoanccek66";
15 const char kAppId7[] = "fbcmoldooppoahjhfflnmljoanccek77";
16 const char kKey1[] = "foo";
17 const char kKey2[] = "bar";
18 const char kKey3[] = "bat";
19 const char kKey4[] = "baz";
20 const char kKey5[] = "foobar";
21 const char kKey6[] = "fu";
22 const char kKey7[] = "meta";
23 const char kIconUrl1[] = "http://www.google.com/icon1.jpg";
24 const char kIconUrl2[] = "http://www.google.com/icon2.jpg";
25 const char kIconUrl3[] = "http://www.google.com/icon3.jpg";
26 const char kIconUrl4[] = "http://www.google.com/icon4.jpg";
27 const char kIconUrl5[] = "http://www.google.com/icon5.jpg";
28 const char kIconUrl6[] = "http://www.google.com/icon6.jpg";
29 const char kIconUrl7[] = "http://www.google.com/icon7.jpg";
30 const char kTitle1[] = "New appointment at 2:15";
31 const char kTitle2[] = "Email from Mark: Upcoming Ski trip";
32 const char kTitle3[] = "Weather alert - light rain tonight.";
33 const char kTitle4[] = "Zombie Alert on I-405";
34 const char kTitle5[] = "5-dimensional plutonian steam hockey scores";
35 const char kTitle6[] = "Conterfactuals Inc Stock report";
36 const char kTitle7[] = "Push Messaging app updated";
37 const char kText1[] = "Space Needle, 12:00 pm";
38 const char kText2[] = "Stevens Pass is our first choice.";
39 const char kText3[] = "More rain expected in the Seattle area tonight.";
40 const char kText4[] = "Traffic slowdown as motorists are hitting zombies";
41 const char kText5[] = "Neptune wins, pi to e";
42 const char kText6[] = "Beef flavored base for soups";
43 const char kText7[] = "You now have the latest version of Push Messaging App.";
44 const char kText1And1[] = "Space Needle, 12:00 pm\nSpace Needle, 12:00 pm";
45 const char kImageUrl1[] = "http://www.google.com/image1.jpg";
46 const char kImageUrl2[] = "http://www.google.com/image2.jpg";
47 const char kImageUrl3[] = "http://www.google.com/image3.jpg";
48 const char kImageUrl4[] = "http://www.google.com/image4.jpg";
49 const char kImageUrl5[] = "http://www.google.com/image5.jpg";
50 const char kImageUrl6[] = "http://www.google.com/image6.jpg";
51 const char kImageUrl7[] = "http://www.google.com/image7.jpg";
52 const char kExpectedOriginUrl[] =
53 "synced-notification://fboilmbenheemaomgaeehigklolhkhnf";
54 const char kDefaultDestinationTitle[] = "Open web page";
55 const char kDefaultDestinationIconUrl[] = "http://www.google.com/image4.jpg";
56 const char kDefaultDestinationUrl[] = "chrome://flags";
57 const char kButtonOneTitle[] = "Read";
58 const char kButtonOneIconUrl[] = "http://www.google.com/image8.jpg";
59 const char kButtonOneUrl[] = "chrome://sync";
60 const char kButtonTwoTitle[] = "Reply";
61 const char kButtonTwoIconUrl[] = "http://www.google.com/image9.jpg";
62 const char kButtonTwoUrl[] = "chrome://about";
63 const char kContainedTitle1[] = "Today's Picnic moved";
64 const char kContainedTitle2[] = "Group Run Today";
65 const char kContainedTitle3[] = "Starcraft Tonight";
66 const char kContainedMessage1[] = "Due to rain, we will be inside the cafe.";
67 const char kContainedMessage2[] = "Meet at noon in the Gym.";
68 const char kContainedMessage3[] = "Let's play starcraft tonight on the LAN.";
70 syncer::SyncData CreateSyncData(
71 const std::string& title,
72 const std::string& text,
73 const std::string& app_icon_url,
74 const std::string& image_url,
75 const std::string& app_id,
76 const std::string& key,
77 const sync_pb::CoalescedSyncedNotification_ReadState read_state) {
78 // CreateLocalData makes a copy of this, so this can safely live
79 // on the stack.
80 sync_pb::EntitySpecifics entity_specifics;
82 // Get a writeable pointer to the sync notifications specifics inside the
83 // entity specifics.
84 sync_pb::SyncedNotificationSpecifics* specifics =
85 entity_specifics.mutable_synced_notification();
87 // Get pointers to sub structures.
88 sync_pb::CoalescedSyncedNotification* coalesced_notification =
89 specifics->mutable_coalesced_notification();
90 sync_pb::SyncedNotificationRenderInfo* render_info =
91 coalesced_notification->mutable_render_info();
92 sync_pb::ExpandedInfo* expanded_info =
93 render_info->mutable_expanded_info();
94 sync_pb::SimpleExpandedLayout* simple_expanded_layout =
95 expanded_info->mutable_simple_expanded_layout();
96 sync_pb::CollapsedInfo* collapsed_info =
97 render_info->mutable_collapsed_info();
98 sync_pb::SimpleCollapsedLayout* simple_collapsed_layout =
99 collapsed_info->mutable_simple_collapsed_layout();
100 sync_pb::SyncedNotificationDestination* default_destination =
101 collapsed_info->mutable_default_destination();
103 coalesced_notification->set_app_id(app_id);
105 coalesced_notification->set_key(key);
107 coalesced_notification->
108 set_priority(static_cast<sync_pb::CoalescedSyncedNotification_Priority>(
109 kProtobufPriority));
111 // Set the title.
112 simple_expanded_layout->set_title(title);
113 simple_collapsed_layout->set_heading(title);
115 // Set the text.
116 simple_expanded_layout->set_text(text);
117 simple_collapsed_layout->set_description(text);
118 simple_collapsed_layout->set_annotation(text);
120 // Set the heading.
121 simple_collapsed_layout->set_heading(title);
123 // Add the collapsed info and set the app_icon_url on it.
124 simple_collapsed_layout->
125 mutable_app_icon()->
126 set_url(app_icon_url);
128 // Add the media object and set the image url on it.
129 simple_collapsed_layout->add_media();
130 simple_collapsed_layout->
131 mutable_media(0)->
132 mutable_image()->
133 set_url(image_url);
135 coalesced_notification->set_creation_time_msec(kFakeCreationTime);
137 coalesced_notification->set_read_state(read_state);
139 // Contained notification one.
140 expanded_info->add_collapsed_info();
141 sync_pb::SimpleCollapsedLayout* notification_layout1 =
142 expanded_info->
143 mutable_collapsed_info(0)->
144 mutable_simple_collapsed_layout();
145 notification_layout1->set_heading(kContainedTitle1);
146 notification_layout1->set_description(kContainedMessage1);
148 // Contained notification two.
149 expanded_info->add_collapsed_info();
150 sync_pb::SimpleCollapsedLayout* notification_layout2 =
151 expanded_info->
152 mutable_collapsed_info(1)->
153 mutable_simple_collapsed_layout();
154 notification_layout2->set_heading(kContainedTitle2);
155 notification_layout2->set_description(kContainedMessage2);
157 // Contained notification three.
158 expanded_info->add_collapsed_info();
159 sync_pb::SimpleCollapsedLayout* notification_layout3 =
160 expanded_info->
161 mutable_collapsed_info(2)->
162 mutable_simple_collapsed_layout();
163 notification_layout3->set_heading(kContainedTitle3);
164 notification_layout3->set_description(kContainedMessage3);
166 // Default Destination.
167 default_destination->set_text(kDefaultDestinationTitle);
168 default_destination->mutable_icon()->set_url(kDefaultDestinationIconUrl);
169 default_destination->mutable_icon()->set_alt_text(kDefaultDestinationTitle);
170 default_destination->set_url(kDefaultDestinationUrl);
172 // Buttons are represented as targets.
174 // Button One.
175 collapsed_info->add_target();
176 sync_pb::SyncedNotificationAction* action1 =
177 collapsed_info->mutable_target(0)->mutable_action();
178 action1->set_text(kButtonOneTitle);
179 action1->mutable_icon()->set_url(kButtonOneIconUrl);
180 action1->mutable_icon()->set_alt_text(kButtonOneTitle);
181 action1->set_url(kButtonOneUrl);
183 // Button Two.
184 collapsed_info->add_target();
185 sync_pb::SyncedNotificationAction* action2 =
186 collapsed_info->mutable_target(1)->mutable_action();
187 action2->set_text(kButtonOneTitle);
188 action2->mutable_icon()->set_url(kButtonTwoIconUrl);
189 action2->mutable_icon()->set_alt_text(kButtonTwoTitle);
190 action2->set_url(kButtonTwoUrl);
192 syncer::SyncData sync_data = syncer::SyncData::CreateLocalData(
193 "syncer::SYNCED_NOTIFICATIONS",
194 "ChromeNotifierServiceUnitTest",
195 entity_specifics);
197 return sync_data;