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

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc

Issue 10829029: sync: don't display one-click if setup is in progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 8 years, 5 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/ui/sync/one_click_signin_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
index 99e560987cf2db9df984e1cf71aaa92933128dc5..40b6e0e1f6c4ba3c76e521ab428bc8f78fc0a06b 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc
@@ -7,6 +7,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_manager_fake.h"
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/sync/test_profile_sync_service.h"
#include "chrome/browser/ui/sync/one_click_signin_helper.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
@@ -53,6 +55,42 @@ void OneClickSigninHelperTest::SetUp() {
// as needed.
}
+class OneClickTestProfileSyncService : public TestProfileSyncService {
+ public:
+ virtual ~OneClickTestProfileSyncService() {}
+
+ // Helper routine to be used in conjunction with
+ // ProfileKeyedServiceFactory::SetTestingFactory().
+ static ProfileKeyedService* Build(Profile* profile) {
+ return new OneClickTestProfileSyncService(profile);
+ }
+
+ // Need to control this for certain tests.
+ virtual bool FirstSetupInProgress() const OVERRIDE {
+ return first_setup_in_progress_;
+ }
+
+ // Controls return value of FirstSetupInProgress. Because some bits
+ // of UI depend on that value, it's useful to control it separately
+ // from the internal work and components that are triggered (such as
+ // ReconfigureDataTypeManager) to facilitate unit tests.
+ void set_first_setup_in_progress(bool in_progress) {
+ first_setup_in_progress_ = in_progress;
+ }
+
+ private:
+ explicit OneClickTestProfileSyncService(Profile* profile)
+ : TestProfileSyncService(NULL,
+ profile,
+ NULL,
+ ProfileSyncService::MANUAL_START,
+ false, // synchronous_backend_init
+ base::Closure()),
+ first_setup_in_progress_(false) {}
+
+ bool first_setup_in_progress_;
+};
+
content::WebContents* OneClickSigninHelperTest::CreateMockWebContents(
bool use_incognito,
const std::string& username) {
@@ -67,7 +105,6 @@ content::WebContents* OneClickSigninHelperTest::CreateMockWebContents(
signin_manager->StartSignIn(username, std::string(), std::string(),
std::string());
}
-
return CreateTestWebContents();
}
@@ -104,6 +141,22 @@ TEST_F(OneClickSigninHelperTest, CanOffer) {
EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, false));
}
+TEST_F(OneClickSigninHelperTest, CanOfferFirstSetup) {
+ content::WebContents* web_contents = CreateMockWebContents(false, "");
+
+ // Invoke OneClickTestProfileSyncService factory function and grab result.
+ OneClickTestProfileSyncService* sync =
+ static_cast<OneClickTestProfileSyncService*>(
+ ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ static_cast<Profile*>(browser_context()),
+ OneClickTestProfileSyncService::Build));
+
+ sync->set_first_setup_in_progress(true);
+
+ EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, true));
+ EXPECT_TRUE(OneClickSigninHelper::CanOffer(web_contents, false));
+}
+
TEST_F(OneClickSigninHelperTest, CanOfferProfileConnected) {
content::WebContents* web_contents = CreateMockWebContents(false,
"foo@gmail.com");
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698