#include "base/values.h"
#include "chrome/browser/signin/fake_signin_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
-#include "chrome/browser/signin/signin_manager.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/test/base/testing_profile.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/browser/web_ui.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
-#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
using ::testing::_;
return NULL;
}
virtual void SetController(content::WebUIController* controller) OVERRIDE {}
- virtual ui::ScaleFactor GetDeviceScaleFactor() const OVERRIDE {
- return ui::SCALE_FACTOR_100P;
+ virtual float GetDeviceScaleFactor() const OVERRIDE {
+ return 1.0f;
}
virtual const base::string16& GetOverriddenTitle() const OVERRIDE {
return temp_string_;
}
virtual void OverrideTitle(const base::string16& title) OVERRIDE {}
- virtual content::PageTransition GetLinkTransitionType() const OVERRIDE {
- return content::PAGE_TRANSITION_LINK;
+ virtual ui::PageTransition GetLinkTransitionType() const OVERRIDE {
+ return ui::PAGE_TRANSITION_LINK;
}
- virtual void SetLinkTransitionType(content::PageTransition type) OVERRIDE {}
+ virtual void SetLinkTransitionType(ui::PageTransition type) OVERRIDE {}
virtual int GetBindings() const OVERRIDE {
return 0;
}
WillRepeatedly(Return(GetAllTypes()));
EXPECT_CALL(*mock_pss_, GetActiveDataTypes()).
WillRepeatedly(Return(GetAllTypes()));
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
+ WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, EncryptEverythingEnabled()).
WillRepeatedly(Return(false));
}
.WillRepeatedly(Return(false));
// Ensure that the user is not signed in before calling |HandleStartSignin()|.
SigninManager* manager = static_cast<SigninManager*>(mock_signin_);
- manager->SignOut();
+ manager->SignOut(signin_metrics::SIGNOUT_TEST);
handler_->HandleStartSignin(NULL);
// Sync setup hands off control to the gaia login tab.
}
#endif // !defined(OS_CHROMEOS)
+// Verifies that the sync setup is terminated correctly when the
+// sync is disabled.
+TEST_F(SyncSetupHandlerTest, HandleSetupUIWhenSyncDisabled) {
+ EXPECT_CALL(*mock_pss_, IsManaged()).WillRepeatedly(Return(true));
+ handler_->HandleShowSetupUI(NULL);
+
+ // Sync setup is closed when sync is disabled.
+ EXPECT_EQ(NULL,
+ LoginUIServiceFactory::GetForProfile(
+ profile_.get())->current_login_ui());
+ ASSERT_FALSE(handler_->is_configuring_sync());
+}
+
// Verifies that the handler correctly handles a cancellation when
// it is displaying the spinner to the user.
TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
CheckBool(dictionary, "passphraseFailed", false);
CheckBool(dictionary, "showSyncEverythingPage", false);
CheckBool(dictionary, "syncAllDataTypes", true);
+ CheckBool(dictionary, "encryptAllDataAllowed", true);
CheckBool(dictionary, "encryptAllData", false);
CheckBool(dictionary, "usePassphrase", false);
}
.WillRepeatedly(Return(false));
EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
.WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed())
+ .WillRepeatedly(Return(true));
SetupInitializedProfileSyncService();
EXPECT_CALL(*mock_pss_, EnableEncryptEverything());
EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
FakeAuthStatusProvider provider(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())->
signin_error_controller());
- provider.SetAuthError(kTestUser, error_);
+ provider.SetAuthError(kTestUser, kTestUser, error_);
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
CheckBool(dictionary, "encryptAllData", true);
}
+
+TEST_F(SyncSetupHandlerTest, ShowSetupEncryptAllDisallowed) {
+ EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase())
+ .WillRepeatedly(Return(false));
+ SetupInitializedProfileSyncService();
+ SetDefaultExpectationsForConfigPage();
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
+ WillRepeatedly(Return(false));
+
+ // This should display the sync setup dialog (not login).
+ handler_->OpenSyncSetup();
+
+ ExpectConfig();
+ const TestWebUI::CallData& data = web_ui_.call_data()[0];
+ base::DictionaryValue* dictionary;
+ ASSERT_TRUE(data.arg2->GetAsDictionary(&dictionary));
+ CheckBool(dictionary, "encryptAllData", false);
+ CheckBool(dictionary, "encryptAllDataAllowed", false);
+}
+
+TEST_F(SyncSetupHandlerTest, TurnOnEncryptAllDisallowed) {
+ std::string args = GetConfiguration(
+ NULL, SYNC_ALL_DATA, GetAllTypes(), std::string(), ENCRYPT_ALL_DATA);
+ base::ListValue list_args;
+ list_args.Append(new base::StringValue(args));
+ EXPECT_CALL(*mock_pss_, IsPassphraseRequiredForDecryption())
+ .WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, IsPassphraseRequired())
+ .WillRepeatedly(Return(false));
+ SetupInitializedProfileSyncService();
+ EXPECT_CALL(*mock_pss_, EncryptEverythingAllowed()).
+ WillRepeatedly(Return(false));
+ EXPECT_CALL(*mock_pss_, EnableEncryptEverything()).Times(0);
+ EXPECT_CALL(*mock_pss_, OnUserChoseDatatypes(true, _));
+ handler_->HandleConfigure(&list_args);
+
+ // Ensure that we navigated to the "done" state since we don't need a
+ // passphrase.
+ ExpectDone();
+}
+