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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser. h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_browser. h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/launcher/launcher_model.h" 11 #include "ash/launcher/launcher_model.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/run_loop.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/test_extension_system.h" 19 #include "chrome/browser/extensions/test_extension_system.h"
20 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 20 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
21 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 21 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/testing_pref_service_syncable.h" 24 #include "chrome/test/base/testing_pref_service_syncable.h"
25 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
26 #include "content/public/test/test_browser_thread.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 #if defined(OS_CHROMEOS) 29 #if defined(OS_CHROMEOS)
30 #include "chrome/browser/chromeos/login/user_manager.h" 30 #include "chrome/browser/chromeos/login/user_manager.h"
31 #include "chrome/browser/chromeos/settings/cros_settings.h" 31 #include "chrome/browser/chromeos/settings/cros_settings.h"
32 #include "chrome/browser/chromeos/settings/device_settings_service.h" 32 #include "chrome/browser/chromeos/settings/device_settings_service.h"
33 #endif 33 #endif
34 34
35 using extensions::Extension; 35 using extensions::Extension;
36 using extensions::Manifest; 36 using extensions::Manifest;
37 37
38 class ChromeLauncherControllerPerBrowserTest : public testing::Test { 38 class ChromeLauncherControllerPerBrowserTest : public testing::Test {
39 protected: 39 protected:
40 ChromeLauncherControllerPerBrowserTest() 40 ChromeLauncherControllerPerBrowserTest()
41 : ui_thread_(content::BrowserThread::UI, &loop_), 41 : profile_(new TestingProfile()),
42 file_thread_(content::BrowserThread::FILE, &loop_),
43 profile_(new TestingProfile()),
44 extension_service_(NULL) { 42 extension_service_(NULL) {
45 DictionaryValue manifest; 43 DictionaryValue manifest;
46 manifest.SetString("name", "launcher controller test extension"); 44 manifest.SetString("name", "launcher controller test extension");
47 manifest.SetString("version", "1"); 45 manifest.SetString("version", "1");
48 manifest.SetString("description", "for testing pinned apps"); 46 manifest.SetString("description", "for testing pinned apps");
49 47
50 extensions::TestExtensionSystem* extension_system( 48 extensions::TestExtensionSystem* extension_system(
51 static_cast<extensions::TestExtensionSystem*>( 49 static_cast<extensions::TestExtensionSystem*>(
52 extensions::ExtensionSystem::Get(profile_.get()))); 50 extensions::ExtensionSystem::Get(profile_.get())));
53 extension_service_ = extension_system->CreateExtensionService( 51 extension_service_ = extension_system->CreateExtensionService(
(...skipping 20 matching lines...) Expand all
74 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 72 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
75 manifest, 73 manifest,
76 Extension::NO_FLAGS, 74 Extension::NO_FLAGS,
77 extension_misc::kGoogleSearchAppId, 75 extension_misc::kGoogleSearchAppId,
78 &error); 76 &error);
79 } 77 }
80 78
81 virtual void TearDown() OVERRIDE { 79 virtual void TearDown() OVERRIDE {
82 profile_.reset(); 80 profile_.reset();
83 // Execute any pending deletion tasks. 81 // Execute any pending deletion tasks.
84 loop_.RunUntilIdle(); 82 base::RunLoop().RunUntilIdle();
85 } 83 }
86 84
87 void InsertPrefValue(base::ListValue* pref_value, 85 void InsertPrefValue(base::ListValue* pref_value,
88 int index, 86 int index,
89 const std::string& extension_id) { 87 const std::string& extension_id) {
90 base::DictionaryValue* entry = new DictionaryValue(); 88 base::DictionaryValue* entry = new DictionaryValue();
91 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); 89 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id);
92 pref_value->Insert(index, entry); 90 pref_value->Insert(index, entry);
93 } 91 }
94 92
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 break; 136 break;
139 default: 137 default:
140 result += "Unknown"; 138 result += "Unknown";
141 break; 139 break;
142 } 140 }
143 } 141 }
144 return result; 142 return result;
145 } 143 }
146 144
147 // Needed for extension service & friends to work. 145 // Needed for extension service & friends to work.
148 base::MessageLoop loop_; 146 content::TestBrowserThreadBundle thread_bundle_;
149 content::TestBrowserThread ui_thread_;
150 content::TestBrowserThread file_thread_;
151 147
152 #if defined OS_CHROMEOS 148 #if defined OS_CHROMEOS
153 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 149 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
154 chromeos::ScopedTestCrosSettings test_cros_settings_; 150 chromeos::ScopedTestCrosSettings test_cros_settings_;
155 chromeos::ScopedTestUserManager test_user_manager_; 151 chromeos::ScopedTestUserManager test_user_manager_;
156 #endif 152 #endif
157 153
158 scoped_refptr<Extension> extension1_; 154 scoped_refptr<Extension> extension1_;
159 scoped_refptr<Extension> extension2_; 155 scoped_refptr<Extension> extension2_;
160 scoped_refptr<Extension> extension3_; 156 scoped_refptr<Extension> extension3_;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 453
458 GetAppLaunchers(&controller, &actual_launchers); 454 GetAppLaunchers(&controller, &actual_launchers);
459 EXPECT_EQ(expected_launchers, actual_launchers); 455 EXPECT_EQ(expected_launchers, actual_launchers);
460 456
461 // Install |extension2| and verify it shows up between the other two. 457 // Install |extension2| and verify it shows up between the other two.
462 extension_service_->AddExtension(extension2_.get()); 458 extension_service_->AddExtension(extension2_.get());
463 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); 459 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id());
464 GetAppLaunchers(&controller, &actual_launchers); 460 GetAppLaunchers(&controller, &actual_launchers);
465 EXPECT_EQ(expected_launchers, actual_launchers); 461 EXPECT_EQ(expected_launchers, actual_launchers);
466 } 462 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698