Commit d4d2174e authored by Sharon Yang's avatar Sharon Yang Committed by Commit Bot

[Fuchsia] Test Cleanup, incorporate use of fidl::Equals

We have now discovered fidl::Equals, so instances of individually
checking each field in fidl objects can be replaced with fidl::Equals.

An additional test cleanup in frame_impl_unittests.

Test: CQ
Bug: 1039849
Change-Id: Ifcb4e2fb87000fed558ef50aa786c77ea04b5ad0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1995742
Commit-Queue: Sharon Yang <yangsharon@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734952}
parent 345bfdd8
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/no_destructor.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -80,6 +81,23 @@ class ContextImplTest : public cr_fuchsia::WebEngineBrowserTest { ...@@ -80,6 +81,23 @@ class ContextImplTest : public cr_fuchsia::WebEngineBrowserTest {
DISALLOW_COPY_AND_ASSIGN(ContextImplTest); DISALLOW_COPY_AND_ASSIGN(ContextImplTest);
}; };
fuchsia::web::Cookie CreateExpectedCookie() {
fuchsia::web::Cookie cookie;
fuchsia::web::CookieId id;
id.set_name("foo");
id.set_path("/");
id.set_domain("127.0.0.1");
cookie.set_id(std::move(id));
cookie.set_value("bar");
return cookie;
}
const fuchsia::web::Cookie& ExpectedCookie() {
static const base::NoDestructor<fuchsia::web::Cookie> expected_cookie(
CreateExpectedCookie());
return *expected_cookie;
}
} // namespace } // namespace
// BrowserContext with persistent storage stores cookies such that they can // BrowserContext with persistent storage stores cookies such that they can
...@@ -100,10 +118,7 @@ IN_PROC_BROWSER_TEST_F(ContextImplTest, PersistentCookieStore) { ...@@ -100,10 +118,7 @@ IN_PROC_BROWSER_TEST_F(ContextImplTest, PersistentCookieStore) {
std::vector<fuchsia::web::Cookie> cookies = GetCookies(); std::vector<fuchsia::web::Cookie> cookies = GetCookies();
ASSERT_EQ(cookies.size(), 1u); ASSERT_EQ(cookies.size(), 1u);
ASSERT_TRUE(cookies[0].has_id()); ASSERT_TRUE(cookies[0].has_id());
ASSERT_TRUE(cookies[0].id().has_name()); EXPECT_TRUE(fidl::Equals(cookies[0], ExpectedCookie()));
ASSERT_TRUE(cookies[0].has_value());
EXPECT_EQ(cookies[0].id().name(), "foo");
EXPECT_EQ(cookies[0].value(), "bar");
// Check that the cookie persists beyond the lifetime of the Frame by // Check that the cookie persists beyond the lifetime of the Frame by
// releasing the Frame and re-querying the CookieStore. // releasing the Frame and re-querying the CookieStore.
...@@ -113,10 +128,7 @@ IN_PROC_BROWSER_TEST_F(ContextImplTest, PersistentCookieStore) { ...@@ -113,10 +128,7 @@ IN_PROC_BROWSER_TEST_F(ContextImplTest, PersistentCookieStore) {
cookies = GetCookies(); cookies = GetCookies();
ASSERT_EQ(cookies.size(), 1u); ASSERT_EQ(cookies.size(), 1u);
ASSERT_TRUE(cookies[0].has_id()); ASSERT_TRUE(cookies[0].has_id());
ASSERT_TRUE(cookies[0].id().has_name()); EXPECT_TRUE(fidl::Equals(cookies[0], ExpectedCookie()));
ASSERT_TRUE(cookies[0].has_value());
EXPECT_EQ(cookies[0].id().name(), "foo");
EXPECT_EQ(cookies[0].value(), "bar");
} }
// Suite for tests which run the BrowserContext in incognito mode (no data // Suite for tests which run the BrowserContext in incognito mode (no data
...@@ -166,9 +178,5 @@ IN_PROC_BROWSER_TEST_F(IncognitoContextImplTest, InMemoryCookieStore) { ...@@ -166,9 +178,5 @@ IN_PROC_BROWSER_TEST_F(IncognitoContextImplTest, InMemoryCookieStore) {
std::vector<fuchsia::web::Cookie> cookies = GetCookies(); std::vector<fuchsia::web::Cookie> cookies = GetCookies();
ASSERT_EQ(cookies.size(), 1u); ASSERT_EQ(cookies.size(), 1u);
ASSERT_TRUE(cookies[0].has_id()); EXPECT_TRUE(fidl::Equals(cookies[0], ExpectedCookie()));
ASSERT_TRUE(cookies[0].id().has_name());
ASSERT_TRUE(cookies[0].has_value());
EXPECT_EQ(cookies[0].id().name(), "foo");
EXPECT_EQ(cookies[0].value(), "bar");
} }
...@@ -75,7 +75,7 @@ TEST(FrameImplUnitTest, DiffNavigationEntriesGoBackAndForward) { ...@@ -75,7 +75,7 @@ TEST(FrameImplUnitTest, DiffNavigationEntriesGoBackAndForward) {
EXPECT_FALSE(difference.IsEmpty()); EXPECT_FALSE(difference.IsEmpty());
EXPECT_TRUE(difference.has_can_go_back()); EXPECT_TRUE(difference.has_can_go_back());
EXPECT_TRUE(difference.has_can_go_back()); EXPECT_TRUE(difference.has_can_go_forward());
EXPECT_TRUE(difference.can_go_forward()); EXPECT_TRUE(difference.can_go_forward());
EXPECT_FALSE(difference.can_go_back()); EXPECT_FALSE(difference.can_go_back());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment