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. 4 5 #include "components/dom_distiller/core/article_entry.h" 6 7 #include "sync/protocol/sync.pb.h" 8 #include "testing/gtest/include/gtest/gtest.h" 9 10 using sync_pb::EntitySpecifics; 11 using sync_pb::ArticlePage; 12 using sync_pb::ArticleSpecifics; 13 using testing::AssertionResult; 14 using testing::AssertionSuccess; 15 using testing::AssertionFailure; 16 17 namespace dom_distiller { 18 19 TEST(DomDistillerArticleEntryTest, TestIsEntryValid) { 20 ArticleEntry entry; 21 EXPECT_FALSE(IsEntryValid(entry)); 22 entry.set_entry_id("entry0"); 23 EXPECT_TRUE(IsEntryValid(entry)); 24 ArticleEntryPage* page0 = entry.add_pages(); 25 EXPECT_FALSE(IsEntryValid(entry)); 26 page0->set_url("example.com/1"); 27 EXPECT_TRUE(IsEntryValid(entry)); 28 } 29 30 TEST(DomDistillerArticleEntryTest, TestAreEntriesEqual) { 31 ArticleEntry left; 32 ArticleEntry right; 33 left.set_entry_id("entry0"); 34 right.set_entry_id("entry1"); 35 EXPECT_FALSE(AreEntriesEqual(left, right)); 36 right = left; 37 EXPECT_TRUE(AreEntriesEqual(left, right)); 38 39 left.set_title("a title"); 40 EXPECT_FALSE(AreEntriesEqual(left, right)); 41 right.set_title("a different title"); 42 EXPECT_FALSE(AreEntriesEqual(left, right)); 43 right.set_title("a title"); 44 EXPECT_TRUE(AreEntriesEqual(left, right)); 45 46 ArticleEntryPage left_page; 47 left_page.set_url("example.com/1"); 48 *left.add_pages() = left_page; 49 50 EXPECT_FALSE(AreEntriesEqual(left, right)); 51 52 ArticleEntryPage right_page; 53 right_page.set_url("foo.example.com/1"); 54 *right.add_pages() = right_page; 55 EXPECT_FALSE(AreEntriesEqual(left, right)); 56 57 right = left; 58 EXPECT_TRUE(AreEntriesEqual(left, right)); 59 60 *right.add_pages() = right_page; 61 EXPECT_FALSE(AreEntriesEqual(left, right)); 62 } 63 64 } // namespace dom_distiller 65