Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / sync / one_click_signin_helper_unittest.cc
index c0f8ef3..bf982c3 100644 (file)
@@ -30,6 +30,8 @@
 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
 #include "chrome/common/pref_names.h"
+#include "chrome/grit/chromium_strings.h"
+#include "chrome/grit/generated_resources.h"
 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
 #include "chrome/test/base/testing_browser_process.h"
 #include "chrome/test/base/testing_pref_service_syncable.h"
@@ -47,8 +49,6 @@
 #include "content/public/common/frame_navigate_params.h"
 #include "content/public/common/url_constants.h"
 #include "content/public/test/mock_render_process_host.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
 #include "testing/gmock/include/gmock/gmock.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "ui/base/l10n/l10n_util.h"
@@ -63,9 +63,9 @@ namespace {
 // a pending navigation.
 class MockWebContentsDelegate : public content::WebContentsDelegate {
  public:
-   MOCK_METHOD2(OpenURLFromTab,
-                content::WebContents*(content::WebContents* source,
-                                      const content::OpenURLParams& params));
+  MOCK_METHOD2(OpenURLFromTab,
+               content::WebContents*(content::WebContents* source,
+                                     const content::OpenURLParams& params));
 };
 
 class SigninManagerMock : public FakeSigninManager {
@@ -166,7 +166,7 @@ class TestProfileIOData : public ProfileIOData {
 };
 
 class TestURLRequest : public base::SupportsUserData {
-public:
+ public:
   TestURLRequest() {}
   virtual ~TestURLRequest() {}
 };
@@ -392,10 +392,12 @@ class OneClickSigninHelperIncognitoTest : public OneClickSigninHelperTest {
 
 content::BrowserContext*
 OneClickSigninHelperIncognitoTest::CreateBrowserContext() {
-  // Builds an incognito profile to run this test.
-  TestingProfile::Builder builder;
-  builder.SetIncognito();
-  return builder.Build().release();
+  // Simulate an incognito profile to run this test. RenderViewHostTestHarness
+  // takes ownership of the return value, so it can't be a "proper" incognito
+  // profile, since they are owned by their parent, non-incognito profile.
+  scoped_ptr<TestingProfile> profile = TestingProfile::Builder().Build();
+  profile->ForceIncognito(true);
+  return profile.release();
 }
 
 TEST_F(OneClickSigninHelperTest, CanOfferNoContents) {
@@ -669,43 +671,6 @@ TEST_F(OneClickSigninHelperIncognitoTest, ShowInfoBarUIThreadIncognito) {
       rvh()->GetRoutingID());
 }
 
-// If Chrome signin is triggered from a webstore install, and user chooses to
-// config sync, then Chrome should redirect immediately to sync settings page,
-// and upon successful setup, redirect back to webstore.
-TEST_F(OneClickSigninHelperTest, SigninFromWebstoreWithConfigSyncfirst) {
-  SetUpSigninManager(std::string());
-  EXPECT_CALL(*signin_manager_, IsAllowedUsername(_))
-      .WillRepeatedly(Return(true));
-
-  OneClickTestProfileSyncService* sync_service =
-      static_cast<OneClickTestProfileSyncService*>(
-          ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
-              profile(), OneClickTestProfileSyncService::Build));
-  sync_service->set_sync_initialized(true);
-
-  content::WebContents* contents = web_contents();
-
-  OneClickSigninHelper::CreateForWebContentsWithPasswordManager(contents, NULL);
-  OneClickSigninHelper* helper =
-      OneClickSigninHelper::FromWebContents(contents);
-  helper->SetDoNotClearPendingEmailForTesting();
-  helper->set_do_not_start_sync_for_testing();
-
-  GURL continueUrl("https://chrome.google.com/webstore?source=5");
-  OneClickSigninHelper::ShowInfoBarUIThread(
-      "session_index", "user@gmail.com",
-      OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT,
-      signin::SOURCE_WEBSTORE_INSTALL,
-      continueUrl, process()->GetID(), rvh()->GetRoutingID());
-
-  SubmitGAIAPassword(helper);
-
-  NavigateAndCommit(GURL("https://chrome.google.com/webstore?source=3"));
-  helper->DidStopLoading(rvh());
-  sync_service->NotifyObservers();
-  EXPECT_EQ(GURL(continueUrl), contents->GetVisibleURL());
-}
-
 // Checks that the state of OneClickSigninHelper is cleaned when there is a
 // navigation away from the sign in flow that is not triggered by the
 // web contents.
@@ -721,7 +686,7 @@ TEST_F(OneClickSigninHelperTest, CleanTransientStateOnNavigate) {
   content::LoadCommittedDetails details;
   content::FrameNavigateParams params;
   params.url = GURL("http://crbug.com");
-  params.transition = content::PAGE_TRANSITION_TYPED;
+  params.transition = ui::PAGE_TRANSITION_TYPED;
   helper->DidNavigateMainFrame(details, params);
 
   EXPECT_EQ(OneClickSigninHelper::AUTO_ACCEPT_NONE, helper->auto_accept_);
@@ -733,7 +698,7 @@ TEST_F(OneClickSigninHelperTest, NoRedirectToNTPWithPendingEntry) {
 
   const GURL fooWebUIURL("chrome://foo");
   controller.LoadURL(fooWebUIURL, content::Referrer(),
-                     content::PAGE_TRANSITION_TYPED, std::string());
+                     ui::PAGE_TRANSITION_TYPED, std::string());
   EXPECT_EQ(fooWebUIURL, controller.GetPendingEntry()->GetURL());
 
   MockWebContentsDelegate delegate;