Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / content / browser / appcache / appcache_quota_client_unittest.cc
index 88346ee..a453ee1 100644 (file)
@@ -16,8 +16,8 @@
 namespace content {
 
 // Declared to shorten the line lengths.
-static const quota::StorageType kTemp = quota::kStorageTypeTemporary;
-static const quota::StorageType kPerm = quota::kStorageTypePersistent;
+static const storage::StorageType kTemp = storage::kStorageTypeTemporary;
+static const storage::StorageType kPerm = storage::kStorageTypePersistent;
 
 // Base class for our test fixtures.
 class AppCacheQuotaClientTest : public testing::Test {
@@ -31,85 +31,76 @@ class AppCacheQuotaClientTest : public testing::Test {
         kOriginB("http://host:8000"),
         kOriginOther("http://other"),
         usage_(0),
-        delete_status_(quota::kQuotaStatusUnknown),
+        delete_status_(storage::kQuotaStatusUnknown),
         num_get_origin_usage_completions_(0),
         num_get_origins_completions_(0),
         num_delete_origins_completions_(0),
-        weak_factory_(this) {
-  }
+        weak_factory_(this) {}
 
-  int64 GetOriginUsage(
-      quota::QuotaClient* client,
-      const GURL& origin,
-      quota::StorageType type) {
+  int64 GetOriginUsage(storage::QuotaClient* client,
+                       const GURL& origin,
+                       storage::StorageType type) {
     usage_ = -1;
     AsyncGetOriginUsage(client, origin, type);
     base::RunLoop().RunUntilIdle();
     return usage_;
   }
 
-  const std::set<GURL>& GetOriginsForType(
-      quota::QuotaClient* client,
-      quota::StorageType type) {
+  const std::set<GURL>& GetOriginsForType(storage::QuotaClient* client,
+                                          storage::StorageType type) {
     origins_.clear();
     AsyncGetOriginsForType(client, type);
     base::RunLoop().RunUntilIdle();
     return origins_;
   }
 
-  const std::set<GURL>& GetOriginsForHost(
-      quota::QuotaClient* client,
-      quota::StorageType type,
-      const std::string& host) {
+  const std::set<GURL>& GetOriginsForHost(storage::QuotaClient* client,
+                                          storage::StorageType type,
+                                          const std::string& host) {
     origins_.clear();
     AsyncGetOriginsForHost(client, type, host);
     base::RunLoop().RunUntilIdle();
     return origins_;
   }
 
-  quota::QuotaStatusCode DeleteOriginData(
-      quota::QuotaClient* client,
-      quota::StorageType type,
-      const GURL& origin) {
-    delete_status_ = quota::kQuotaStatusUnknown;
+  storage::QuotaStatusCode DeleteOriginData(storage::QuotaClient* client,
+                                            storage::StorageType type,
+                                            const GURL& origin) {
+    delete_status_ = storage::kQuotaStatusUnknown;
     AsyncDeleteOriginData(client, type, origin);
     base::RunLoop().RunUntilIdle();
     return delete_status_;
   }
 
-  void AsyncGetOriginUsage(
-      quota::QuotaClient* client,
-      const GURL& origin,
-      quota::StorageType type) {
+  void AsyncGetOriginUsage(storage::QuotaClient* client,
+                           const GURL& origin,
+                           storage::StorageType type) {
     client->GetOriginUsage(
         origin, type,
         base::Bind(&AppCacheQuotaClientTest::OnGetOriginUsageComplete,
                    weak_factory_.GetWeakPtr()));
   }
 
-  void AsyncGetOriginsForType(
-      quota::QuotaClient* client,
-      quota::StorageType type) {
+  void AsyncGetOriginsForType(storage::QuotaClient* client,
+                              storage::StorageType type) {
     client->GetOriginsForType(
         type,
         base::Bind(&AppCacheQuotaClientTest::OnGetOriginsComplete,
                    weak_factory_.GetWeakPtr()));
   }
 
-  void AsyncGetOriginsForHost(
-      quota::QuotaClient* client,
-      quota::StorageType type,
-      const std::string& host) {
+  void AsyncGetOriginsForHost(storage::QuotaClient* client,
+                              storage::StorageType type,
+                              const std::string& host) {
     client->GetOriginsForHost(
         type, host,
         base::Bind(&AppCacheQuotaClientTest::OnGetOriginsComplete,
                    weak_factory_.GetWeakPtr()));
   }
 
-  void AsyncDeleteOriginData(
-      quota::QuotaClient* client,
-      quota::StorageType type,
-      const GURL& origin) {
+  void AsyncDeleteOriginData(storage::QuotaClient* client,
+                             storage::StorageType type,
+                             const GURL& origin) {
     client->DeleteOriginData(
         origin, type,
         base::Bind(&AppCacheQuotaClientTest::OnDeleteOriginDataComplete,
@@ -147,7 +138,7 @@ class AppCacheQuotaClientTest : public testing::Test {
     origins_ = origins;
   }
 
-  void OnDeleteOriginDataComplete(quota::QuotaStatusCode status) {
+  void OnDeleteOriginDataComplete(storage::QuotaStatusCode status) {
     ++num_delete_origins_completions_;
     delete_status_ = status;
   }
@@ -155,7 +146,7 @@ class AppCacheQuotaClientTest : public testing::Test {
   base::MessageLoop message_loop_;
   int64 usage_;
   std::set<GURL> origins_;
-  quota::QuotaStatusCode delete_status_;
+  storage::QuotaStatusCode delete_status_;
   int num_get_origin_usage_completions_;
   int num_get_origins_completions_;
   int num_delete_origins_completions_;
@@ -181,8 +172,8 @@ TEST_F(AppCacheQuotaClientTest, EmptyService) {
   EXPECT_TRUE(GetOriginsForType(client, kPerm).empty());
   EXPECT_TRUE(GetOriginsForHost(client, kTemp, kOriginA.host()).empty());
   EXPECT_TRUE(GetOriginsForHost(client, kPerm, kOriginA.host()).empty());
-  EXPECT_EQ(quota::kQuotaStatusOk, DeleteOriginData(client, kTemp, kOriginA));
-  EXPECT_EQ(quota::kQuotaStatusOk, DeleteOriginData(client, kPerm, kOriginA));
+  EXPECT_EQ(storage::kQuotaStatusOk, DeleteOriginData(client, kTemp, kOriginA));
+  EXPECT_EQ(storage::kQuotaStatusOk, DeleteOriginData(client, kPerm, kOriginA));
 
   Call_NotifyAppCacheDestroyed(client);
   Call_OnQuotaManagerDestroyed(client);
@@ -199,9 +190,9 @@ TEST_F(AppCacheQuotaClientTest, NoService) {
   EXPECT_TRUE(GetOriginsForType(client, kPerm).empty());
   EXPECT_TRUE(GetOriginsForHost(client, kTemp, kOriginA.host()).empty());
   EXPECT_TRUE(GetOriginsForHost(client, kPerm, kOriginA.host()).empty());
-  EXPECT_EQ(quota::kQuotaErrorAbort,
+  EXPECT_EQ(storage::kQuotaErrorAbort,
             DeleteOriginData(client, kTemp, kOriginA));
-  EXPECT_EQ(quota::kQuotaErrorAbort,
+  EXPECT_EQ(storage::kQuotaErrorAbort,
             DeleteOriginData(client, kPerm, kOriginA));
 
   Call_OnQuotaManagerDestroyed(client);
@@ -276,17 +267,15 @@ TEST_F(AppCacheQuotaClientTest, DeleteOriginData) {
 
   // Perm deletions are short circuited in the Client and
   // should not reach the AppCacheServiceImpl.
-  EXPECT_EQ(quota::kQuotaStatusOk,
-            DeleteOriginData(client, kPerm, kOriginA));
+  EXPECT_EQ(storage::kQuotaStatusOk, DeleteOriginData(client, kPerm, kOriginA));
   EXPECT_EQ(0, mock_service_.delete_called_count());
 
-  EXPECT_EQ(quota::kQuotaStatusOk,
-            DeleteOriginData(client, kTemp, kOriginA));
+  EXPECT_EQ(storage::kQuotaStatusOk, DeleteOriginData(client, kTemp, kOriginA));
   EXPECT_EQ(1, mock_service_.delete_called_count());
 
   mock_service_.set_mock_delete_appcaches_for_origin_result(
       net::ERR_ABORTED);
-  EXPECT_EQ(quota::kQuotaErrorAbort,
+  EXPECT_EQ(storage::kQuotaErrorAbort,
             DeleteOriginData(client, kTemp, kOriginA));
   EXPECT_EQ(2, mock_service_.delete_called_count());
 
@@ -368,7 +357,7 @@ TEST_F(AppCacheQuotaClientTest, DestroyServiceWithPending) {
   EXPECT_EQ(3, num_delete_origins_completions_);
   EXPECT_EQ(0, usage_);
   EXPECT_TRUE(origins_.empty());
-  EXPECT_EQ(quota::kQuotaErrorAbort, delete_status_);
+  EXPECT_EQ(storage::kQuotaErrorAbort, delete_status_);
 
   Call_OnQuotaManagerDestroyed(client);
 }
@@ -421,13 +410,13 @@ TEST_F(AppCacheQuotaClientTest, DestroyWithDeleteInProgress) {
 
   // Should have been aborted.
   EXPECT_EQ(1, num_delete_origins_completions_);
-  EXPECT_EQ(quota::kQuotaErrorAbort, delete_status_);
+  EXPECT_EQ(storage::kQuotaErrorAbort, delete_status_);
 
   // A real completion callback from the service should
   // be dropped if it comes in after NotifyAppCacheDestroyed.
   base::RunLoop().RunUntilIdle();
   EXPECT_EQ(1, num_delete_origins_completions_);
-  EXPECT_EQ(quota::kQuotaErrorAbort, delete_status_);
+  EXPECT_EQ(storage::kQuotaErrorAbort, delete_status_);
 
   Call_OnQuotaManagerDestroyed(client);
 }