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

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/extensions/extension_updater.h" 32 #include "chrome/browser/extensions/extension_updater.h"
33 #include "chrome/browser/extensions/external_extension_provider_impl.h" 33 #include "chrome/browser/extensions/external_extension_provider_impl.h"
34 #include "chrome/browser/extensions/external_extension_provider_interface.h" 34 #include "chrome/browser/extensions/external_extension_provider_interface.h"
35 #include "chrome/browser/extensions/external_pref_extension_loader.h" 35 #include "chrome/browser/extensions/external_pref_extension_loader.h"
36 #include "chrome/browser/extensions/pack_extension_job.cc" 36 #include "chrome/browser/extensions/pack_extension_job.cc"
37 #include "chrome/browser/extensions/pending_extension_info.h" 37 #include "chrome/browser/extensions/pending_extension_info.h"
38 #include "chrome/browser/extensions/pending_extension_manager.h" 38 #include "chrome/browser/extensions/pending_extension_manager.h"
39 #include "chrome/browser/prefs/browser_prefs.h" 39 #include "chrome/browser/prefs/browser_prefs.h"
40 #include "chrome/browser/prefs/pref_service_mock_builder.h" 40 #include "chrome/browser/prefs/pref_service_mock_builder.h"
41 #include "chrome/browser/prefs/scoped_user_pref_update.h" 41 #include "chrome/browser/prefs/scoped_user_pref_update.h"
42 #include "chrome/common/chrome_notification_types.h"
42 #include "chrome/common/chrome_paths.h" 43 #include "chrome/common/chrome_paths.h"
43 #include "chrome/common/chrome_switches.h" 44 #include "chrome/common/chrome_switches.h"
44 #include "chrome/common/extensions/extension.h" 45 #include "chrome/common/extensions/extension.h"
45 #include "chrome/common/extensions/extension_constants.h" 46 #include "chrome/common/extensions/extension_constants.h"
46 #include "chrome/common/extensions/extension_resource.h" 47 #include "chrome/common/extensions/extension_resource.h"
47 #include "chrome/common/extensions/url_pattern.h" 48 #include "chrome/common/extensions/url_pattern.h"
48 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
49 #include "chrome/common/url_constants.h" 50 #include "chrome/common/url_constants.h"
50 #include "chrome/test/testing_profile.h" 51 #include "chrome/test/testing_profile.h"
51 #include "content/browser/appcache/chrome_appcache_service.h" 52 #include "content/browser/appcache/chrome_appcache_service.h"
52 #include "content/browser/browser_thread.h" 53 #include "content/browser/browser_thread.h"
53 #include "content/browser/file_system/browser_file_system_helper.h" 54 #include "content/browser/file_system/browser_file_system_helper.h"
54 #include "content/browser/in_process_webkit/dom_storage_context.h" 55 #include "content/browser/in_process_webkit/dom_storage_context.h"
55 #include "content/browser/in_process_webkit/webkit_context.h" 56 #include "content/browser/in_process_webkit/webkit_context.h"
56 #include "content/common/json_value_serializer.h" 57 #include "content/common/json_value_serializer.h"
57 #include "content/common/notification_registrar.h" 58 #include "content/common/notification_registrar.h"
58 #include "content/common/notification_service.h" 59 #include "content/common/notification_service.h"
59 #include "content/common/notification_type.h"
60 #include "googleurl/src/gurl.h" 60 #include "googleurl/src/gurl.h"
61 #include "net/base/cookie_monster.h" 61 #include "net/base/cookie_monster.h"
62 #include "net/base/cookie_options.h" 62 #include "net/base/cookie_options.h"
63 #include "net/url_request/url_request_context.h" 63 #include "net/url_request/url_request_context.h"
64 #include "net/url_request/url_request_context_getter.h" 64 #include "net/url_request/url_request_context_getter.h"
65 #include "testing/gtest/include/gtest/gtest.h" 65 #include "testing/gtest/include/gtest/gtest.h"
66 #include "testing/platform_test.h" 66 #include "testing/platform_test.h"
67 #include "webkit/database/database_tracker.h" 67 #include "webkit/database/database_tracker.h"
68 #include "webkit/database/database_util.h" 68 #include "webkit/database/database_util.h"
69 #include "webkit/quota/quota_manager.h" 69 #include "webkit/quota/quota_manager.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 485 }
486 486
487 void ExtensionServiceTestBase::SetUp() { 487 void ExtensionServiceTestBase::SetUp() {
488 ExtensionErrorReporter::GetInstance()->ClearErrors(); 488 ExtensionErrorReporter::GetInstance()->ClearErrors();
489 } 489 }
490 490
491 class ExtensionServiceTest 491 class ExtensionServiceTest
492 : public ExtensionServiceTestBase, public NotificationObserver { 492 : public ExtensionServiceTestBase, public NotificationObserver {
493 public: 493 public:
494 ExtensionServiceTest() : installed_(NULL) { 494 ExtensionServiceTest() : installed_(NULL) {
495 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 495 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
496 NotificationService::AllSources()); 496 NotificationService::AllSources());
497 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 497 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
498 NotificationService::AllSources()); 498 NotificationService::AllSources());
499 registrar_.Add(this, NotificationType::EXTENSION_INSTALLED, 499 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED,
500 NotificationService::AllSources()); 500 NotificationService::AllSources());
501 } 501 }
502 502
503 virtual void Observe(NotificationType type, 503 virtual void Observe(int type,
504 const NotificationSource& source, 504 const NotificationSource& source,
505 const NotificationDetails& details) { 505 const NotificationDetails& details) {
506 switch (type.value) { 506 switch (type) {
507 case NotificationType::EXTENSION_LOADED: { 507 case chrome::NOTIFICATION_EXTENSION_LOADED: {
508 const Extension* extension = Details<const Extension>(details).ptr(); 508 const Extension* extension = Details<const Extension>(details).ptr();
509 loaded_.push_back(make_scoped_refptr(extension)); 509 loaded_.push_back(make_scoped_refptr(extension));
510 // The tests rely on the errors being in a certain order, which can vary 510 // The tests rely on the errors being in a certain order, which can vary
511 // depending on how filesystem iteration works. 511 // depending on how filesystem iteration works.
512 std::stable_sort(loaded_.begin(), loaded_.end(), ExtensionsOrder()); 512 std::stable_sort(loaded_.begin(), loaded_.end(), ExtensionsOrder());
513 break; 513 break;
514 } 514 }
515 515
516 case NotificationType::EXTENSION_UNLOADED: { 516 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
517 const Extension* e = 517 const Extension* e =
518 Details<UnloadedExtensionInfo>(details)->extension; 518 Details<UnloadedExtensionInfo>(details)->extension;
519 unloaded_id_ = e->id(); 519 unloaded_id_ = e->id();
520 ExtensionList::iterator i = 520 ExtensionList::iterator i =
521 std::find(loaded_.begin(), loaded_.end(), e); 521 std::find(loaded_.begin(), loaded_.end(), e);
522 // TODO(erikkay) fix so this can be an assert. Right now the tests 522 // TODO(erikkay) fix so this can be an assert. Right now the tests
523 // are manually calling clear() on loaded_, so this isn't doable. 523 // are manually calling clear() on loaded_, so this isn't doable.
524 if (i == loaded_.end()) 524 if (i == loaded_.end())
525 return; 525 return;
526 loaded_.erase(i); 526 loaded_.erase(i);
527 break; 527 break;
528 } 528 }
529 case NotificationType::EXTENSION_INSTALLED: 529 case chrome::NOTIFICATION_EXTENSION_INSTALLED:
530 installed_ = Details<const Extension>(details).ptr(); 530 installed_ = Details<const Extension>(details).ptr();
531 break; 531 break;
532 532
533 default: 533 default:
534 DCHECK(false); 534 DCHECK(false);
535 } 535 }
536 } 536 }
537 537
538 void AddMockExternalProvider(ExternalExtensionProviderInterface* provider) { 538 void AddMockExternalProvider(ExternalExtensionProviderInterface* provider) {
539 service_->AddProviderForTesting(provider); 539 service_->AddProviderForTesting(provider);
(...skipping 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after
3187 EXPECT_EQ("My name is simple.", loaded_[0]->name()); 3187 EXPECT_EQ("My name is simple.", loaded_[0]->name());
3188 3188
3189 // These are untouched by re-localization. 3189 // These are untouched by re-localization.
3190 EXPECT_EQ("My name is simple.", loaded_[1]->name()); 3190 EXPECT_EQ("My name is simple.", loaded_[1]->name());
3191 EXPECT_EQ("no l10n", loaded_[2]->name()); 3191 EXPECT_EQ("no l10n", loaded_[2]->name());
3192 } 3192 }
3193 3193
3194 class ExtensionsReadyRecorder : public NotificationObserver { 3194 class ExtensionsReadyRecorder : public NotificationObserver {
3195 public: 3195 public:
3196 ExtensionsReadyRecorder() : ready_(false) { 3196 ExtensionsReadyRecorder() : ready_(false) {
3197 registrar_.Add(this, NotificationType::EXTENSIONS_READY, 3197 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
3198 NotificationService::AllSources()); 3198 NotificationService::AllSources());
3199 } 3199 }
3200 3200
3201 void set_ready(bool value) { ready_ = value; } 3201 void set_ready(bool value) { ready_ = value; }
3202 bool ready() { return ready_; } 3202 bool ready() { return ready_; }
3203 3203
3204 private: 3204 private:
3205 virtual void Observe(NotificationType type, 3205 virtual void Observe(int type,
3206 const NotificationSource& source, 3206 const NotificationSource& source,
3207 const NotificationDetails& details) { 3207 const NotificationDetails& details) {
3208 switch (type.value) { 3208 switch (type) {
3209 case NotificationType::EXTENSIONS_READY: 3209 case chrome::NOTIFICATION_EXTENSIONS_READY:
3210 ready_ = true; 3210 ready_ = true;
3211 break; 3211 break;
3212 default: 3212 default:
3213 NOTREACHED(); 3213 NOTREACHED();
3214 } 3214 }
3215 } 3215 }
3216 3216
3217 NotificationRegistrar registrar_; 3217 NotificationRegistrar registrar_;
3218 bool ready_; 3218 bool ready_;
3219 }; 3219 };
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
3765 ASSERT_FALSE(AddPendingSyncInstall()); 3765 ASSERT_FALSE(AddPendingSyncInstall());
3766 3766
3767 // Wait for the external source to install. 3767 // Wait for the external source to install.
3768 WaitForCrxInstall(crx_path_, true); 3768 WaitForCrxInstall(crx_path_, true);
3769 ASSERT_TRUE(IsCrxInstalled()); 3769 ASSERT_TRUE(IsCrxInstalled());
3770 3770
3771 // Now that the extension is installed, sync request should fail 3771 // Now that the extension is installed, sync request should fail
3772 // because the extension is already installed. 3772 // because the extension is already installed.
3773 ASSERT_FALSE(AddPendingSyncInstall()); 3773 ASSERT_FALSE(AddPendingSyncInstall());
3774 } 3774 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.cc ('k') | chrome/browser/extensions/extension_startup_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698