Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3238)

Unified Diff: chrome/browser/profiles/profile_attributes_storage_unittest.cc

Issue 2712883005: Sign out profile when local_state file has been changed. (Closed)
Patch Set: Merge from master Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_attributes_entry.cc ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_attributes_storage_unittest.cc
diff --git a/chrome/browser/profiles/profile_attributes_storage_unittest.cc b/chrome/browser/profiles/profile_attributes_storage_unittest.cc
index b789da40ba4ba4df09f377c08e59982fe62d547d..fc1ef5dc61683262515f6b9d3a81f122c5a047f5 100644
--- a/chrome/browser/profiles/profile_attributes_storage_unittest.cc
+++ b/chrome/browser/profiles/profile_attributes_storage_unittest.cc
@@ -12,12 +12,17 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/supervised_user/supervised_user_constants.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using ::testing::Mock;
+using ::testing::_;
+
namespace {
// The ProfileMetadataEntry accessors aren't just plain old accessors to local
// members so they'll be tested. The following helpers will make the testing
@@ -132,6 +137,13 @@ class ProfileAttributesStorageTest : public testing::Test {
content::TestBrowserThreadBundle thread_bundle_;
};
+class ProfileAttributesTestObserver
+ : public ProfileAttributesStorage::Observer {
+ public:
+ MOCK_METHOD1(OnProfileSigninRequiredChanged,
+ void(const base::FilePath& profile_path));
+};
+
TEST_F(ProfileAttributesStorageTest, ProfileNotFound) {
EXPECT_EQ(0U, storage()->GetNumberOfProfiles());
@@ -436,3 +448,30 @@ TEST_F(ProfileAttributesStorageTest, ChooseAvatarIconIndexForNewProfile) {
storage()->ChooseAvatarIconIndexForNewProfile());
}
}
+
+TEST_F(ProfileAttributesStorageTest, ProfileForceSigninLock) {
+ signin_util::SetForceSigninForTesting(true);
+ ProfileAttributesTestObserver observer;
+ ProfileAttributesEntry* entry;
+
+ AddTestingProfile();
+ ASSERT_TRUE(storage()->GetProfileAttributesWithPath(
+ GetProfilePath("testing_profile_path0"), &entry));
+ storage()->AddObserver(&observer);
+ ASSERT_FALSE(entry->IsSigninRequired());
+
+ EXPECT_CALL(observer, OnProfileSigninRequiredChanged(_)).Times(0);
+ entry->LockForceSigninProfile(false);
+ ASSERT_FALSE(entry->IsSigninRequired());
+ Mock::VerifyAndClear(&observer);
+
+ EXPECT_CALL(observer, OnProfileSigninRequiredChanged(_)).Times(1);
+ entry->LockForceSigninProfile(true);
+ ASSERT_TRUE(entry->IsSigninRequired());
+ Mock::VerifyAndClear(&observer);
+
+ EXPECT_CALL(observer, OnProfileSigninRequiredChanged(_)).Times(1);
+ entry->SetIsSigninRequired(false);
+ ASSERT_FALSE(entry->IsSigninRequired());
+ Mock::VerifyAndClear(&observer);
+}
« no previous file with comments | « chrome/browser/profiles/profile_attributes_entry.cc ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698