OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/ntp_snippets/remote/remote_suggestion.h" | 5 #include "components/ntp_snippets/remote/remote_suggestion.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 proto.add_ids("foo"); | 387 proto.add_ids("foo"); |
388 proto.add_ids("bar"); | 388 proto.add_ids("bar"); |
389 proto.set_title("a suggestion title"); | 389 proto.set_title("a suggestion title"); |
390 proto.set_snippet("the snippet describing the suggestion."); | 390 proto.set_snippet("the snippet describing the suggestion."); |
391 proto.set_salient_image_url("http://google.com/logo/"); | 391 proto.set_salient_image_url("http://google.com/logo/"); |
392 proto.set_publish_date(1476095492); | 392 proto.set_publish_date(1476095492); |
393 proto.set_expiry_date(1476354691); | 393 proto.set_expiry_date(1476354691); |
394 proto.set_score(0.1f); | 394 proto.set_score(0.1f); |
395 proto.set_dismissed(false); | 395 proto.set_dismissed(false); |
396 proto.set_remote_category_id(1); | 396 proto.set_remote_category_id(1); |
397 auto source = proto.add_sources(); | 397 auto* source = proto.add_sources(); |
398 source->set_url("http://cool-suggestions.com/"); | 398 source->set_url("http://cool-suggestions.com/"); |
399 source->set_publisher_name("Great Suggestions Inc."); | 399 source->set_publisher_name("Great Suggestions Inc."); |
400 source->set_amp_url("http://cdn.ampproject.org/c/foo/"); | 400 source->set_amp_url("http://cdn.ampproject.org/c/foo/"); |
401 | 401 |
402 std::unique_ptr<RemoteSuggestion> snippet = | 402 std::unique_ptr<RemoteSuggestion> snippet = |
403 RemoteSuggestion::CreateFromProto(proto); | 403 RemoteSuggestion::CreateFromProto(proto); |
404 ASSERT_THAT(snippet, NotNull()); | 404 ASSERT_THAT(snippet, NotNull()); |
405 // The snippet database relies on the fact that the first id in the protocol | 405 // The snippet database relies on the fact that the first id in the protocol |
406 // buffer is considered the unique id. | 406 // buffer is considered the unique id. |
407 EXPECT_EQ(snippet->id(), "foo"); | 407 EXPECT_EQ(snippet->id(), "foo"); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 EXPECT_THAT(sugg.score(), Eq(9001)); | 526 EXPECT_THAT(sugg.score(), Eq(9001)); |
527 EXPECT_THAT(sugg.download_suggestion_extra(), IsNull()); | 527 EXPECT_THAT(sugg.download_suggestion_extra(), IsNull()); |
528 EXPECT_THAT(sugg.recent_tab_suggestion_extra(), IsNull()); | 528 EXPECT_THAT(sugg.recent_tab_suggestion_extra(), IsNull()); |
529 ASSERT_THAT(sugg.notification_extra(), NotNull()); | 529 ASSERT_THAT(sugg.notification_extra(), NotNull()); |
530 EXPECT_THAT(sugg.notification_extra()->deadline.ToJavaTime(), | 530 EXPECT_THAT(sugg.notification_extra()->deadline.ToJavaTime(), |
531 Eq(1467291697000)); | 531 Eq(1467291697000)); |
532 } | 532 } |
533 | 533 |
534 } // namespace | 534 } // namespace |
535 } // namespace ntp_snippets | 535 } // namespace ntp_snippets |
OLD | NEW |