| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/drive/drive_app_registry.h" | 5 #include "chrome/browser/drive/drive_app_registry.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/drive/drive_app_registry_observer.h" | 11 #include "chrome/browser/drive/drive_app_registry_observer.h" |
| 12 #include "chrome/browser/drive/fake_drive_service.h" | 12 #include "chrome/browser/drive/fake_drive_service.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "google_apis/drive/drive_api_parser.h" | 14 #include "google_apis/drive/drive_api_parser.h" |
| 15 #include "google_apis/drive/gdata_wapi_parser.h" | 15 #include "google_apis/drive/gdata_wapi_parser.h" |
| 16 #include "google_apis/drive/test_util.h" | 16 #include "google_apis/drive/test_util.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace drive { | 19 namespace drive { |
| 20 | 20 |
| 21 class TestDriveAppRegistryObserver : public DriveAppRegistryObserver { | 21 class TestDriveAppRegistryObserver : public DriveAppRegistryObserver { |
| 22 public: | 22 public: |
| 23 explicit TestDriveAppRegistryObserver(DriveAppRegistry* registry) | 23 explicit TestDriveAppRegistryObserver(DriveAppRegistry* registry) |
| 24 : registry_(registry), | 24 : registry_(registry), |
| 25 update_count_(0) { | 25 update_count_(0) { |
| 26 registry_->AddObserver(this); | 26 registry_->AddObserver(this); |
| 27 } | 27 } |
| 28 virtual ~TestDriveAppRegistryObserver() { | 28 ~TestDriveAppRegistryObserver() override { registry_->RemoveObserver(this); } |
| 29 registry_->RemoveObserver(this); | |
| 30 } | |
| 31 | 29 |
| 32 int update_count() const { return update_count_; } | 30 int update_count() const { return update_count_; } |
| 33 | 31 |
| 34 private: | 32 private: |
| 35 // DriveAppRegistryObserver overrides: | 33 // DriveAppRegistryObserver overrides: |
| 36 virtual void OnDriveAppRegistryUpdated() override { ++update_count_; } | 34 void OnDriveAppRegistryUpdated() override { ++update_count_; } |
| 37 | 35 |
| 38 DriveAppRegistry* registry_; | 36 DriveAppRegistry* registry_; |
| 39 int update_count_; | 37 int update_count_; |
| 40 DISALLOW_COPY_AND_ASSIGN(TestDriveAppRegistryObserver); | 38 DISALLOW_COPY_AND_ASSIGN(TestDriveAppRegistryObserver); |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 class DriveAppRegistryTest : public testing::Test { | 41 class DriveAppRegistryTest : public testing::Test { |
| 44 protected: | 42 protected: |
| 45 virtual void SetUp() override { | 43 virtual void SetUp() override { |
| 46 fake_drive_service_.reset(new FakeDriveService); | 44 fake_drive_service_.reset(new FakeDriveService); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 google_apis::test_util::CreateCopyResultCallback(&error)); | 216 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 219 base::RunLoop().RunUntilIdle(); | 217 base::RunLoop().RunUntilIdle(); |
| 220 EXPECT_EQ(error, google_apis::HTTP_NOT_FOUND); | 218 EXPECT_EQ(error, google_apis::HTTP_NOT_FOUND); |
| 221 | 219 |
| 222 // Check that the number is not changed this time. | 220 // Check that the number is not changed this time. |
| 223 apps_registry_->GetAppList(&apps); | 221 apps_registry_->GetAppList(&apps); |
| 224 EXPECT_EQ(original_count - 1, apps.size()); | 222 EXPECT_EQ(original_count - 1, apps.size()); |
| 225 } | 223 } |
| 226 | 224 |
| 227 } // namespace drive | 225 } // namespace drive |
| OLD | NEW |