| 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 "extensions/browser/app_window/app_window_geometry_cache.h" | 5 #include "extensions/browser/app_window/app_window_geometry_cache.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 namespace extensions { | 30 namespace extensions { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 const char kWindowId[] = "windowid"; | 33 const char kWindowId[] = "windowid"; |
| 34 const char kWindowId2[] = "windowid2"; | 34 const char kWindowId2[] = "windowid2"; |
| 35 | 35 |
| 36 // Create a very simple extension with id. | 36 // Create a very simple extension with id. |
| 37 scoped_refptr<Extension> CreateExtension(const std::string& id) { | 37 scoped_refptr<Extension> CreateExtension(const std::string& id) { |
| 38 return ExtensionBuilder() | 38 return ExtensionBuilder() |
| 39 .SetManifest(std::move( | 39 .SetManifest( |
| 40 DictionaryBuilder().Set("name", "test").Set("version", "0.1"))) | 40 DictionaryBuilder().Set("name", "test").Set("version", "0.1").Build()) |
| 41 .SetID(id) | 41 .SetID(id) |
| 42 .Build(); | 42 .Build(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 // Base class for tests. | 47 // Base class for tests. |
| 48 class AppWindowGeometryCacheTest : public ExtensionsTest { | 48 class AppWindowGeometryCacheTest : public ExtensionsTest { |
| 49 public: | 49 public: |
| 50 AppWindowGeometryCacheTest() | 50 AppWindowGeometryCacheTest() |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 } | 156 } |
| 157 | 157 |
| 158 std::string AppWindowGeometryCacheTest::AddExtensionWithPrefs( | 158 std::string AppWindowGeometryCacheTest::AddExtensionWithPrefs( |
| 159 const std::string& name) { | 159 const std::string& name) { |
| 160 // Generate the extension with a path based on the name so that extensions | 160 // Generate the extension with a path based on the name so that extensions |
| 161 // with different names will have different IDs. | 161 // with different names will have different IDs. |
| 162 base::FilePath path = | 162 base::FilePath path = |
| 163 browser_context()->GetPath().AppendASCII("Extensions").AppendASCII(name); | 163 browser_context()->GetPath().AppendASCII("Extensions").AppendASCII(name); |
| 164 scoped_refptr<Extension> extension = | 164 scoped_refptr<Extension> extension = |
| 165 ExtensionBuilder() | 165 ExtensionBuilder() |
| 166 .SetManifest(std::move( | 166 .SetManifest(DictionaryBuilder() |
| 167 DictionaryBuilder().Set("name", "test").Set("version", "0.1"))) | 167 .Set("name", "test") |
| 168 .Set("version", "0.1") |
| 169 .Build()) |
| 168 .SetPath(path) | 170 .SetPath(path) |
| 169 .Build(); | 171 .Build(); |
| 170 | 172 |
| 171 extension_prefs_->OnExtensionInstalled( | 173 extension_prefs_->OnExtensionInstalled( |
| 172 extension.get(), | 174 extension.get(), |
| 173 Extension::ENABLED, | 175 Extension::ENABLED, |
| 174 syncer::StringOrdinal::CreateInitialOrdinal(), | 176 syncer::StringOrdinal::CreateInitialOrdinal(), |
| 175 std::string()); | 177 std::string()); |
| 176 return extension->id(); | 178 return extension->id(); |
| 177 } | 179 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 // The first added window should no longer have cached geometry. | 424 // The first added window should no longer have cached geometry. |
| 423 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); | 425 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); |
| 424 // All other windows should still exist. | 426 // All other windows should still exist. |
| 425 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { | 427 for (size_t i = 1; i < AppWindowGeometryCache::kMaxCachedWindows + 1; ++i) { |
| 426 std::string window_id = "window_" + base::SizeTToString(i); | 428 std::string window_id = "window_" + base::SizeTToString(i); |
| 427 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); | 429 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); |
| 428 } | 430 } |
| 429 } | 431 } |
| 430 | 432 |
| 431 } // namespace extensions | 433 } // namespace extensions |
| OLD | NEW |