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

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

Issue 1575523002: Comparison and streaming operators for base::Version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 2446 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(kGoodId)); 2457 EXPECT_FALSE(service()->pending_extension_manager()->IsIdPending(kGoodId));
2458 2458
2459 const Extension* extension = service()->GetExtensionById(kGoodId, true); 2459 const Extension* extension = service()->GetExtensionById(kGoodId, true);
2460 EXPECT_TRUE(extension); 2460 EXPECT_TRUE(extension);
2461 } 2461 }
2462 2462
2463 TEST_F(ExtensionServiceTest, UpdatePendingExtensionWrongVersion) { 2463 TEST_F(ExtensionServiceTest, UpdatePendingExtensionWrongVersion) {
2464 InitializeEmptyExtensionService(); 2464 InitializeEmptyExtensionService();
2465 base::Version other_version("0.1"); 2465 base::Version other_version("0.1");
2466 ASSERT_TRUE(other_version.IsValid()); 2466 ASSERT_TRUE(other_version.IsValid());
2467 ASSERT_FALSE(other_version.Equals(base::Version(kGoodVersion))); 2467 ASSERT_NE(other_version, base::Version(kGoodVersion));
2468 EXPECT_TRUE( 2468 EXPECT_TRUE(
2469 service()->pending_extension_manager()->AddFromSync( 2469 service()->pending_extension_manager()->AddFromSync(
2470 kGoodId, 2470 kGoodId,
2471 GURL(kGoodUpdateURL), 2471 GURL(kGoodUpdateURL),
2472 other_version, 2472 other_version,
2473 &IsExtension, 2473 &IsExtension,
2474 kGoodRemoteInstall, 2474 kGoodRemoteInstall,
2475 kGoodInstalledByCustodian)); 2475 kGoodInstalledByCustodian));
2476 EXPECT_TRUE(service()->pending_extension_manager()->IsIdPending(kGoodId)); 2476 EXPECT_TRUE(service()->pending_extension_manager()->IsIdPending(kGoodId));
2477 2477
(...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5599 kGoodId, 5599 kGoodId,
5600 &kVersion123, 5600 &kVersion123,
5601 kInvalidPathToCrx, 5601 kInvalidPathToCrx,
5602 Manifest::EXTERNAL_PREF, 5602 Manifest::EXTERNAL_PREF,
5603 kCreationFlags, 5603 kCreationFlags,
5604 kDontMarkAcknowledged, 5604 kDontMarkAcknowledged,
5605 kDontInstallImmediately)); 5605 kDontInstallImmediately));
5606 const extensions::PendingExtensionInfo* info; 5606 const extensions::PendingExtensionInfo* info;
5607 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5607 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5608 EXPECT_TRUE(info->version().IsValid()); 5608 EXPECT_TRUE(info->version().IsValid());
5609 EXPECT_TRUE(info->version().Equals(kVersion123)); 5609 EXPECT_EQ(info->version(), kVersion123);
5610 5610
5611 // Adding a newer version overrides the currently pending version. 5611 // Adding a newer version overrides the currently pending version.
5612 EXPECT_TRUE(service()->OnExternalExtensionFileFound( 5612 EXPECT_TRUE(service()->OnExternalExtensionFileFound(
5613 kGoodId, 5613 kGoodId,
5614 &kVersion124, 5614 &kVersion124,
5615 kInvalidPathToCrx, 5615 kInvalidPathToCrx,
5616 Manifest::EXTERNAL_PREF, 5616 Manifest::EXTERNAL_PREF,
5617 kCreationFlags, 5617 kCreationFlags,
5618 kDontMarkAcknowledged, 5618 kDontMarkAcknowledged,
5619 kDontInstallImmediately)); 5619 kDontInstallImmediately));
5620 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5620 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5621 EXPECT_TRUE(info->version().IsValid()); 5621 EXPECT_TRUE(info->version().IsValid());
5622 EXPECT_TRUE(info->version().Equals(kVersion124)); 5622 EXPECT_EQ(info->version(), kVersion124);
5623 5623
5624 // Adding an older version fails. 5624 // Adding an older version fails.
5625 EXPECT_FALSE(service()->OnExternalExtensionFileFound( 5625 EXPECT_FALSE(service()->OnExternalExtensionFileFound(
5626 kGoodId, 5626 kGoodId,
5627 &kVersion123, 5627 &kVersion123,
5628 kInvalidPathToCrx, 5628 kInvalidPathToCrx,
5629 Manifest::EXTERNAL_PREF, 5629 Manifest::EXTERNAL_PREF,
5630 kCreationFlags, 5630 kCreationFlags,
5631 kDontMarkAcknowledged, 5631 kDontMarkAcknowledged,
5632 kDontInstallImmediately)); 5632 kDontInstallImmediately));
5633 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5633 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5634 EXPECT_TRUE(info->version().IsValid()); 5634 EXPECT_TRUE(info->version().IsValid());
5635 EXPECT_TRUE(info->version().Equals(kVersion124)); 5635 EXPECT_EQ(info->version(), kVersion124);
5636 5636
5637 // Adding an older version fails even when coming from a higher-priority 5637 // Adding an older version fails even when coming from a higher-priority
5638 // location. 5638 // location.
5639 EXPECT_FALSE(service()->OnExternalExtensionFileFound( 5639 EXPECT_FALSE(service()->OnExternalExtensionFileFound(
5640 kGoodId, 5640 kGoodId,
5641 &kVersion123, 5641 &kVersion123,
5642 kInvalidPathToCrx, 5642 kInvalidPathToCrx,
5643 Manifest::EXTERNAL_REGISTRY, 5643 Manifest::EXTERNAL_REGISTRY,
5644 kCreationFlags, 5644 kCreationFlags,
5645 kDontMarkAcknowledged, 5645 kDontMarkAcknowledged,
5646 kDontInstallImmediately)); 5646 kDontInstallImmediately));
5647 EXPECT_TRUE((info = pending->GetById(kGoodId))); 5647 EXPECT_TRUE((info = pending->GetById(kGoodId)));
5648 EXPECT_TRUE(info->version().IsValid()); 5648 EXPECT_TRUE(info->version().IsValid());
5649 EXPECT_TRUE(info->version().Equals(kVersion124)); 5649 EXPECT_EQ(info->version(), kVersion124);
5650 5650
5651 // Adding the latest version from the webstore overrides a specific version. 5651 // Adding the latest version from the webstore overrides a specific version.
5652 GURL kUpdateUrl("http://example.com/update"); 5652 GURL kUpdateUrl("http://example.com/update");
5653 EXPECT_TRUE(service()->OnExternalExtensionUpdateUrlFound( 5653 EXPECT_TRUE(service()->OnExternalExtensionUpdateUrlFound(
5654 kGoodId, 5654 kGoodId,
5655 std::string(), 5655 std::string(),
5656 kUpdateUrl, 5656 kUpdateUrl,
5657 Manifest::EXTERNAL_POLICY_DOWNLOAD, 5657 Manifest::EXTERNAL_POLICY_DOWNLOAD,
5658 Extension::NO_FLAGS, 5658 Extension::NO_FLAGS,
5659 false)); 5659 false));
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
6265 6265
6266 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 6266 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
6267 content::Source<Profile>(profile()), 6267 content::Source<Profile>(profile()),
6268 content::NotificationService::NoDetails()); 6268 content::NotificationService::NoDetails());
6269 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 6269 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
6270 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 6270 EXPECT_EQ(0u, registry()->enabled_extensions().size());
6271 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 6271 EXPECT_EQ(0u, registry()->disabled_extensions().size());
6272 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 6272 EXPECT_EQ(0u, registry()->terminated_extensions().size());
6273 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 6273 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
6274 } 6274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698