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

Side by Side Diff: trunk/src/apps/shell_window_geometry_cache_unittest.cc

Issue 23551005: Revert 219709 "Remove the Extensions URLRequestContext." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "apps/shell_window_geometry_cache.h" 5 #include "apps/shell_window_geometry_cache.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/prefs/mock_pref_change_callback.h" 7 #include "base/prefs/mock_pref_change_callback.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "chrome/browser/extensions/extension_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
10 #include "chrome/browser/extensions/test_extension_prefs.h" 10 #include "chrome/browser/extensions/test_extension_prefs.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 12 #include "content/public/test/test_browser_thread.h"
13 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace { 16 namespace {
17 static const char kWindowId[] = "windowid"; 17 static const char kWindowId[] = "windowid";
18 static const char kWindowId2[] = "windowid2"; 18 static const char kWindowId2[] = "windowid2";
19 19
20 const char kWindowGeometryKey[] = "window_geometry"; 20 const char kWindowGeometryKey[] = "window_geometry";
21 } // namespace 21 } // namespace
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 24
25 namespace apps { 25 namespace apps {
26 26
27 // Base class for tests. 27 // Base class for tests.
28 class ShellWindowGeometryCacheTest : public testing::Test { 28 class ShellWindowGeometryCacheTest : public testing::Test {
29 public: 29 public:
30 ShellWindowGeometryCacheTest() { 30 ShellWindowGeometryCacheTest() :
31 ui_thread_(BrowserThread::UI, &ui_message_loop_) {
31 prefs_.reset(new extensions::TestExtensionPrefs( 32 prefs_.reset(new extensions::TestExtensionPrefs(
32 base::MessageLoopForUI::current()->message_loop_proxy().get())); 33 ui_message_loop_.message_loop_proxy().get()));
33 cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs())); 34 cache_.reset(new ShellWindowGeometryCache(&profile_, prefs_->prefs()));
34 cache_->SetSyncDelayForTests(0); 35 cache_->SetSyncDelayForTests(0);
35 } 36 }
36 37
37 void AddGeometryAndLoadExtension( 38 void AddGeometryAndLoadExtension(
38 const std::string& extension_id, 39 const std::string& extension_id,
39 const std::string& window_id, 40 const std::string& window_id,
40 const gfx::Rect& bounds, 41 const gfx::Rect& bounds,
41 const gfx::Rect& screen_bounds, 42 const gfx::Rect& screen_bounds,
42 ui::WindowShowState state); 43 ui::WindowShowState state);
43 44
44 // Spins the UI threads' message loops to make sure any task 45 // Spins the UI threads' message loops to make sure any task
45 // posted to sync the geometry to the value store gets a chance to run. 46 // posted to sync the geometry to the value store gets a chance to run.
46 void WaitForSync(); 47 void WaitForSync();
47 48
48 void LoadExtension(const std::string& extension_id); 49 void LoadExtension(const std::string& extension_id);
49 void UnloadExtension(const std::string& extension_id); 50 void UnloadExtension(const std::string& extension_id);
50 51
51 protected: 52 protected:
52 content::TestBrowserThreadBundle thread_bundle_;
53 TestingProfile profile_; 53 TestingProfile profile_;
54 base::MessageLoopForUI ui_message_loop_;
55 content::TestBrowserThread ui_thread_;
54 scoped_ptr<extensions::TestExtensionPrefs> prefs_; 56 scoped_ptr<extensions::TestExtensionPrefs> prefs_;
55 scoped_ptr<ShellWindowGeometryCache> cache_; 57 scoped_ptr<ShellWindowGeometryCache> cache_;
56 }; 58 };
57 59
58 void ShellWindowGeometryCacheTest::AddGeometryAndLoadExtension( 60 void ShellWindowGeometryCacheTest::AddGeometryAndLoadExtension(
59 const std::string& extension_id, 61 const std::string& extension_id,
60 const std::string& window_id, 62 const std::string& window_id,
61 const gfx::Rect& bounds, 63 const gfx::Rect& bounds,
62 const gfx::Rect& screen_bounds, 64 const gfx::Rect& screen_bounds,
63 ui::WindowShowState state) { 65 ui::WindowShowState state) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // The first added window should no longer have cached geometry. 333 // The first added window should no longer have cached geometry.
332 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL)); 334 EXPECT_FALSE(cache_->GetGeometry(extension_id, "window_0", NULL, NULL, NULL));
333 // All other windows should still exist. 335 // All other windows should still exist.
334 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) { 336 for (size_t i = 1; i < ShellWindowGeometryCache::kMaxCachedWindows + 1; ++i) {
335 std::string window_id = "window_" + base::IntToString(i); 337 std::string window_id = "window_" + base::IntToString(i);
336 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL)); 338 EXPECT_TRUE(cache_->GetGeometry(extension_id, window_id, NULL, NULL, NULL));
337 } 339 }
338 } 340 }
339 341
340 } // namespace extensions 342 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698