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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry_unittest.cc

Issue 815363002: replace COMPILE_ASSERT with static_assert in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 12 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) 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 "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h" 5 #include "extensions/browser/api/declarative_webrequest/webrequest_rules_registr y.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 const GURL urls[] = { 637 const GURL urls[] = {
638 GURL("http://url.example.com"), // matching 638 GURL("http://url.example.com"), // matching
639 GURL("http://www.example.com") // non-matching 639 GURL("http://www.example.com") // non-matching
640 }; 640 };
641 const GURL firstPartyUrls[] = { 641 const GURL firstPartyUrls[] = {
642 GURL("http://www.example.com"), // non-matching 642 GURL("http://www.example.com"), // non-matching
643 GURL("http://fpfc.example.com") // matching 643 GURL("http://fpfc.example.com") // matching
644 }; 644 };
645 // Which rules should match in subsequent test iterations. 645 // Which rules should match in subsequent test iterations.
646 const char* const matchingRuleIds[] = { kRuleId1, kRuleId2 }; 646 const char* const matchingRuleIds[] = { kRuleId1, kRuleId2 };
647 COMPILE_ASSERT(arraysize(urls) == arraysize(firstPartyUrls), 647 static_assert(arraysize(urls) == arraysize(firstPartyUrls),
648 urls_and_firstPartyUrls_need_to_have_the_same_size); 648 "urls and firstPartyUrls must have the same number "
649 COMPILE_ASSERT(arraysize(urls) == arraysize(matchingRuleIds), 649 "of elements");
650 urls_and_matchingRuleIds_need_to_have_the_same_size); 650 static_assert(arraysize(urls) == arraysize(matchingRuleIds),
651 "urls and matchingRuleIds must have the same number "
652 "of elements");
651 net::TestURLRequestContext context; 653 net::TestURLRequestContext context;
652 654
653 for (size_t i = 0; i < arraysize(matchingRuleIds); ++i) { 655 for (size_t i = 0; i < arraysize(matchingRuleIds); ++i) {
654 // Construct the inputs. 656 // Construct the inputs.
655 scoped_ptr<net::URLRequest> http_request(context.CreateRequest( 657 scoped_ptr<net::URLRequest> http_request(context.CreateRequest(
656 urls[i], net::DEFAULT_PRIORITY, NULL, NULL)); 658 urls[i], net::DEFAULT_PRIORITY, NULL, NULL));
657 WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST); 659 WebRequestData request_data(http_request.get(), ON_BEFORE_REQUEST);
658 http_request->set_first_party_for_cookies(firstPartyUrls[i]); 660 http_request->set_first_party_for_cookies(firstPartyUrls[i]);
659 // Now run both rules on the input. 661 // Now run both rules on the input.
660 matches = registry->GetMatches(request_data); 662 matches = registry->GetMatches(request_data);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 // This is a correct match. 813 // This is a correct match.
812 GURL url2("http://foo.com/index.html"); 814 GURL url2("http://foo.com/index.html");
813 scoped_ptr<net::URLRequest> request2(context.CreateRequest( 815 scoped_ptr<net::URLRequest> request2(context.CreateRequest(
814 url2, net::DEFAULT_PRIORITY, NULL, NULL)); 816 url2, net::DEFAULT_PRIORITY, NULL, NULL));
815 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST); 817 WebRequestData request_data2(request2.get(), ON_BEFORE_REQUEST);
816 deltas = registry->CreateDeltas(NULL, request_data2, false); 818 deltas = registry->CreateDeltas(NULL, request_data2, false);
817 EXPECT_EQ(1u, deltas.size()); 819 EXPECT_EQ(1u, deltas.size());
818 } 820 }
819 821
820 } // namespace extensions 822 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698