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

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

Issue 7550020: Apply the new asynchronous CookieMonster API to extension_service_unittest.cc. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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 | « 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_service_unittest.cc
===================================================================
--- chrome/browser/extensions/extension_service_unittest.cc (revision 95355)
+++ chrome/browser/extensions/extension_service_unittest.cc (working copy)
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/bind.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/json/json_reader.h"
@@ -2663,9 +2664,34 @@
UninstallExtension(good_crx, true);
}
+class ExtensionCookieCallback {
+ public:
+ ExtensionCookieCallback()
+ : result_(false),
+ message_loop_factory_(MessageLoop::current()) {}
+
+ void SetCookieCallback(bool result) {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ message_loop_factory_.NewRunnableMethod(&MessageLoop::Quit));
+ result_ = result;
+ }
+
+ void GetAllCookiesCallback(const net::CookieList& list) {
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ message_loop_factory_.NewRunnableMethod(&MessageLoop::Quit));
+ list_ = list;
+ }
+ net::CookieList list_;
+ bool result_;
+ ScopedRunnableMethodFactory<MessageLoop> message_loop_factory_;
+};
+
// Verifies extension state is removed upon uninstall
TEST_F(ExtensionServiceTest, ClearExtensionData) {
InitializeEmptyExtensionService();
+ ExtensionCookieCallback callback;
// Load a test extension.
FilePath path = data_dir_;
@@ -2683,10 +2709,20 @@
cookie_store()->GetCookieMonster();
ASSERT_TRUE(cookie_monster);
net::CookieOptions options;
- cookie_monster->SetCookieWithOptions(ext_url, "dummy=value", options);
- net::CookieList list = cookie_monster->GetAllCookiesForURL(ext_url);
- EXPECT_EQ(1U, list.size());
+ cookie_monster->SetCookieWithOptionsAsync(
+ ext_url, "dummy=value", options,
+ base::Bind(&ExtensionCookieCallback::SetCookieCallback,
+ base::Unretained(&callback)));
+ loop_.RunAllPending();
+ EXPECT_TRUE(callback.result_);
+ cookie_monster->GetAllCookiesForURLAsync(
+ ext_url,
+ base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
+ base::Unretained(&callback)));
+ loop_.RunAllPending();
+ EXPECT_EQ(1U, callback.list_.size());
+
// Open a database.
webkit_database::DatabaseTracker* db_tracker = profile_->GetDatabaseTracker();
string16 db_name = UTF8ToUTF16("db");
@@ -2722,8 +2758,12 @@
loop_.RunAllPending();
// Check that the cookie is gone.
- list = cookie_monster->GetAllCookiesForURL(ext_url);
- EXPECT_EQ(0U, list.size());
+ cookie_monster->GetAllCookiesForURLAsync(
+ ext_url,
+ base::Bind(&ExtensionCookieCallback::GetAllCookiesCallback,
+ base::Unretained(&callback)));
+ loop_.RunAllPending();
+ EXPECT_EQ(0U, callback.list_.size());
// The database should have vanished as well.
origins.clear();
« 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