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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 proto.add_ids("bar"); | 393 proto.add_ids("bar"); |
394 proto.set_title("a suggestion title"); | 394 proto.set_title("a suggestion title"); |
395 proto.set_snippet("the snippet describing the suggestion."); | 395 proto.set_snippet("the snippet describing the suggestion."); |
396 proto.set_salient_image_url("http://google.com/logo/"); | 396 proto.set_salient_image_url("http://google.com/logo/"); |
397 proto.set_publish_date(1476095492); | 397 proto.set_publish_date(1476095492); |
398 proto.set_expiry_date(1476354691); | 398 proto.set_expiry_date(1476354691); |
399 proto.set_score(0.1f); | 399 proto.set_score(0.1f); |
400 proto.set_dismissed(false); | 400 proto.set_dismissed(false); |
401 proto.set_remote_category_id(1); | 401 proto.set_remote_category_id(1); |
402 proto.set_fetch_date(1476364691); | 402 proto.set_fetch_date(1476364691); |
403 auto* source = proto.add_sources(); | 403 auto source = proto.add_sources(); |
404 source->set_url("http://cool-suggestions.com/"); | 404 source->set_url("http://cool-suggestions.com/"); |
405 source->set_publisher_name("Great Suggestions Inc."); | 405 source->set_publisher_name("Great Suggestions Inc."); |
406 source->set_amp_url("http://cdn.ampproject.org/c/foo/"); | 406 source->set_amp_url("http://cdn.ampproject.org/c/foo/"); |
407 | 407 |
408 std::unique_ptr<RemoteSuggestion> snippet = | 408 std::unique_ptr<RemoteSuggestion> snippet = |
409 RemoteSuggestion::CreateFromProto(proto); | 409 RemoteSuggestion::CreateFromProto(proto); |
410 ASSERT_THAT(snippet, NotNull()); | 410 ASSERT_THAT(snippet, NotNull()); |
411 // The snippet database relies on the fact that the first id in the protocol | 411 // The snippet database relies on the fact that the first id in the protocol |
412 // buffer is considered the unique id. | 412 // buffer is considered the unique id. |
413 EXPECT_EQ(snippet->id(), "foo"); | 413 EXPECT_EQ(snippet->id(), "foo"); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 EXPECT_THAT(sugg.score(), Eq(9001)); | 560 EXPECT_THAT(sugg.score(), Eq(9001)); |
561 EXPECT_THAT(sugg.download_suggestion_extra(), IsNull()); | 561 EXPECT_THAT(sugg.download_suggestion_extra(), IsNull()); |
562 EXPECT_THAT(sugg.recent_tab_suggestion_extra(), IsNull()); | 562 EXPECT_THAT(sugg.recent_tab_suggestion_extra(), IsNull()); |
563 ASSERT_THAT(sugg.notification_extra(), NotNull()); | 563 ASSERT_THAT(sugg.notification_extra(), NotNull()); |
564 EXPECT_THAT(sugg.notification_extra()->deadline.ToJavaTime(), | 564 EXPECT_THAT(sugg.notification_extra()->deadline.ToJavaTime(), |
565 Eq(1467291697000)); | 565 Eq(1467291697000)); |
566 } | 566 } |
567 | 567 |
568 } // namespace | 568 } // namespace |
569 } // namespace ntp_snippets | 569 } // namespace ntp_snippets |
OLD | NEW |