forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feed] Create JournalOperation and JournalMutation
Create JournalOperation and JournalMutation on C++ side. Bug: 875143 Change-Id: Ia473ef0f3f528ffe46372f2c8963ebff8ad5bf65 Reviewed-on: https://chromium-review.googlesource.com/1179380 Commit-Queue: Gang Wu <gangwu@chromium.org> Reviewed-by: Sky Malice <skym@chromium.org> Cr-Commit-Position: refs/heads/master@{#584600}
- Loading branch information
Gang Wu
authored and
Commit Bot
committed
Aug 21, 2018
1 parent
0a26fad
commit 58ef920
Showing
13 changed files
with
440 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/feed/core/feed_content_mutation.h" | ||
|
||
#include "components/feed/core/feed_content_operation.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace feed { | ||
|
||
namespace { | ||
|
||
const char kContentkey[] = "ContentKey"; | ||
const char kContentValue[] = "Value"; | ||
const char kContentPrefix[] = "Content"; | ||
|
||
} // namespace | ||
|
||
class FeedContentMutationTest : public testing::Test { | ||
public: | ||
FeedContentMutationTest() = default; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(FeedContentMutationTest); | ||
}; | ||
|
||
TEST_F(FeedContentMutationTest, AppendDeleteOperation) { | ||
ContentMutation mutation; | ||
EXPECT_TRUE(mutation.Empty()); | ||
|
||
mutation.AppendDeleteOperation(kContentkey); | ||
EXPECT_FALSE(mutation.Empty()); | ||
|
||
ContentOperation operation = mutation.TakeFristOperation(); | ||
EXPECT_TRUE(mutation.Empty()); | ||
EXPECT_EQ(operation.type(), ContentOperation::CONTENT_DELETE); | ||
EXPECT_EQ(operation.key(), kContentkey); | ||
} | ||
|
||
TEST_F(FeedContentMutationTest, AppendDeleteAllOperation) { | ||
ContentMutation mutation; | ||
EXPECT_TRUE(mutation.Empty()); | ||
|
||
mutation.AppendDeleteAllOperation(); | ||
EXPECT_FALSE(mutation.Empty()); | ||
|
||
ContentOperation operation = mutation.TakeFristOperation(); | ||
EXPECT_TRUE(mutation.Empty()); | ||
EXPECT_EQ(operation.type(), ContentOperation::CONTENT_DELETE_ALL); | ||
} | ||
|
||
TEST_F(FeedContentMutationTest, AppendDeleteByPrefixOperation) { | ||
ContentMutation mutation; | ||
EXPECT_TRUE(mutation.Empty()); | ||
|
||
mutation.AppendDeleteByPrefixOperation(kContentPrefix); | ||
EXPECT_FALSE(mutation.Empty()); | ||
|
||
ContentOperation operation = mutation.TakeFristOperation(); | ||
EXPECT_TRUE(mutation.Empty()); | ||
EXPECT_EQ(operation.type(), ContentOperation::CONTENT_DELETE_BY_PREFIX); | ||
EXPECT_EQ(operation.prefix(), kContentPrefix); | ||
} | ||
|
||
TEST_F(FeedContentMutationTest, AppendUpsertOperation) { | ||
ContentMutation mutation; | ||
EXPECT_TRUE(mutation.Empty()); | ||
|
||
mutation.AppendUpsertOperation(kContentkey, kContentValue); | ||
EXPECT_FALSE(mutation.Empty()); | ||
|
||
ContentOperation operation = mutation.TakeFristOperation(); | ||
EXPECT_TRUE(mutation.Empty()); | ||
EXPECT_EQ(operation.type(), ContentOperation::CONTENT_UPSERT); | ||
EXPECT_EQ(operation.key(), kContentkey); | ||
EXPECT_EQ(operation.value(), kContentValue); | ||
} | ||
|
||
} // namespace feed |
Oops, something went wrong.