| Index: chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
|
| diff --git a/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc b/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
|
| index 9ded86efc10967c5cc86e16b1e69f743f309dfef..4f400d0fcc066dec90941e7cb1a364fa244eb714 100644
|
| --- a/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
|
| +++ b/chrome/browser/chromeos/extensions/extension_tab_util_delegate_chromeos_unittest.cc
|
| @@ -7,15 +7,31 @@
|
| #include <string>
|
|
|
| #include "chromeos/login/login_state.h"
|
| +#include "chromeos/login/scoped_test_public_session_login_state.h"
|
| +#include "extensions/common/extension.h"
|
| +#include "extensions/common/extension_builder.h"
|
| +#include "extensions/common/value_builder.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace extensions {
|
|
|
| namespace {
|
|
|
| +const char kWhitelistedId[] = "cbkkbcmdlboombapidmoeolnmdacpkch";
|
| +// Use an extension ID that will never be whitelisted.
|
| +const char kNonWhitelistedId[] = "bogus";
|
| +
|
| const char kTestUrl[] = "http://www.foo.bar/baz?key=val";
|
| const char kFilteredUrl[] = "http://www.foo.bar/";
|
|
|
| +scoped_refptr<Extension> CreateExtension(const std::string& id) {
|
| + return ExtensionBuilder()
|
| + .SetManifest(
|
| + DictionaryBuilder().Set("name", "test").Set("version", "0.1").Build())
|
| + .SetID(id)
|
| + .Build();
|
| +}
|
| +
|
| } // namespace
|
|
|
| class ExtensionTabUtilDelegateChromeOSTest : public testing::Test {
|
| @@ -30,25 +46,40 @@ void ExtensionTabUtilDelegateChromeOSTest::SetUp() {
|
| tab_.url.reset(new std::string(kTestUrl));
|
| }
|
|
|
| -TEST_F(ExtensionTabUtilDelegateChromeOSTest, NoFilteringOutsidePublicSession) {
|
| +TEST_F(ExtensionTabUtilDelegateChromeOSTest,
|
| + NoFilteringOutsidePublicSessionForWhitelisted) {
|
| ASSERT_FALSE(chromeos::LoginState::IsInitialized());
|
|
|
| - delegate_.ScrubTabForExtension(nullptr, nullptr, &tab_);
|
| + auto extension = CreateExtension(kWhitelistedId);
|
| + delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
|
| EXPECT_EQ(kTestUrl, *tab_.url);
|
| }
|
|
|
| -TEST_F(ExtensionTabUtilDelegateChromeOSTest, ScrubURL) {
|
| - // Set Public Session state.
|
| - chromeos::LoginState::Initialize();
|
| - chromeos::LoginState::Get()->SetLoggedInState(
|
| - chromeos::LoginState::LOGGED_IN_ACTIVE,
|
| - chromeos::LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT);
|
| +TEST_F(ExtensionTabUtilDelegateChromeOSTest,
|
| + NoFilteringOutsidePublicSessionForNonWhitelisted) {
|
| + ASSERT_FALSE(chromeos::LoginState::IsInitialized());
|
|
|
| - delegate_.ScrubTabForExtension(nullptr, nullptr, &tab_);
|
| - EXPECT_EQ(kFilteredUrl, *tab_.url);
|
| + auto extension = CreateExtension(kNonWhitelistedId);
|
| + delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
|
| + EXPECT_EQ(kTestUrl, *tab_.url);
|
| +}
|
|
|
| - // Reset state at the end of test.
|
| - chromeos::LoginState::Shutdown();
|
| +TEST_F(ExtensionTabUtilDelegateChromeOSTest,
|
| + NoFilteringInsidePublicSessionForWhitelisted) {
|
| + chromeos::ScopedTestPublicSessionLoginState state;
|
| +
|
| + auto extension = CreateExtension(kWhitelistedId);
|
| + delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
|
| + EXPECT_EQ(kTestUrl, *tab_.url);
|
| +}
|
| +
|
| +TEST_F(ExtensionTabUtilDelegateChromeOSTest,
|
| + FilterInsidePublicSessionNonWhitelisted) {
|
| + chromeos::ScopedTestPublicSessionLoginState state;
|
| +
|
| + auto extension = CreateExtension(kNonWhitelistedId);
|
| + delegate_.ScrubTabForExtension(extension.get(), nullptr, &tab_);
|
| + EXPECT_EQ(kFilteredUrl, *tab_.url);
|
| }
|
|
|
| } // namespace extensions
|
|
|