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

Unified Diff: chrome/browser/extensions/extension_webstore_private_browsertest.cc

Issue 4115005: Add incognito mode to tests for extension webstore priviate APIs.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_webstore_private_browsertest.cc
===================================================================
--- chrome/browser/extensions/extension_webstore_private_browsertest.cc (revision 64768)
+++ chrome/browser/extensions/extension_webstore_private_browsertest.cc (working copy)
@@ -4,11 +4,13 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_signin.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/extensions/extension_webstore_private_api.h"
#include "chrome/browser/net/gaia/token_service.h"
+#include "chrome/browser/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
@@ -82,7 +84,11 @@
delegate->OnLoginSuccess();
// Fake a token available notification.
- TokenService* token_service = tab_contents->profile()->GetTokenService();
+ Profile* profile = tab_contents->profile();
+ if (profile->IsOffTheRecord()) {
+ profile = g_browser_process->profile_manager()->GetDefaultProfile();
+ }
+ TokenService* token_service = profile->GetTokenService();
token_service->IssueAuthTokenForTest(GaiaConstants::kGaiaService,
"new_token");
} else {
@@ -122,10 +128,11 @@
return base_url.ReplaceComponents(replacements);
}
- void RunLoginTest(const std::string& relative_path,
- const std::string& initial_login,
- bool login_succeeds,
- const std::string& login_result) {
+ void RunLoginTestImpl(bool incognito,
+ const std::string& relative_path,
+ const std::string& initial_login,
+ bool login_succeeds,
+ const std::string& login_result) {
// Clear the token service so previous tests don't affect things.
TokenService* token_service = browser()->profile()->GetTokenService();
token_service->ResetCredentialsInMemory();
@@ -142,13 +149,33 @@
ExtensionTestMessageListener listener("success", false);
GURL url = GetUrl(relative_path);
- ui_test_utils::NavigateToURL(browser(), url);
+ if (incognito) {
+ ui_test_utils::OpenURLOffTheRecord(browser()->profile(), url);
+ } else {
+ ui_test_utils::NavigateToURL(browser(), url);
+ }
EXPECT_TRUE(listener.WaitUntilSatisfied());
WebstorePrivateApi::SetTestingBrowserSignin(NULL);
WebstorePrivateApi::SetTestingProfileSyncService(NULL);
}
+ void RunLoginTest(const std::string& relative_path,
+ const std::string& initial_login,
+ bool login_succeeds,
+ const std::string& login_result) {
+ RunLoginTestImpl(true,
+ relative_path,
+ initial_login,
+ login_succeeds,
+ login_result);
+ RunLoginTestImpl(false,
+ relative_path,
+ initial_login,
+ login_succeeds,
+ login_result);
+ }
+
protected:
std::string test_url_base_;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698