Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / api / identity / extension_token_key_unittest.cc
blob80b3858d557feddc4c1619e2aeda7221c1f04798
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/api/identity/extension_token_key.h"
7 #include <algorithm>
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(IdentityExtensionTokenKeyTest, Ordering) {
15 std::string extension_id1("ext_id_1");
16 std::string extension_id2("ext_id_2");
17 std::set<std::string> scopes1;
18 std::set<std::string> scopes2;
19 std::set<std::string> scopes3;
21 scopes1.insert("a");
22 scopes1.insert("b");
23 scopes2.insert("a");
25 std::vector<std::string> extension_ids;
26 extension_ids.push_back(extension_id1);
27 extension_ids.push_back(extension_id2);
29 std::vector<std::string> user_ids;
30 user_ids.push_back("user_id_1");
31 user_ids.push_back("user_id_2");
33 std::vector<std::set<std::string> > scopesets;
34 scopesets.push_back(scopes1);
35 scopesets.push_back(scopes2);
36 scopesets.push_back(scopes3);
38 std::vector<extensions::ExtensionTokenKey> keys;
39 typedef std::vector<extensions::ExtensionTokenKey>::const_iterator
40 ExtensionTokenKeyIterator;
42 std::vector<std::string>::const_iterator extension_it;
43 std::vector<std::string>::const_iterator user_it;
44 std::vector<std::set<std::string> >::const_iterator scope_it;
46 for (extension_it = extension_ids.begin();
47 extension_it != extension_ids.end();
48 ++extension_it) {
49 for (user_it = user_ids.begin(); user_it != user_ids.end(); ++user_it) {
50 for (scope_it = scopesets.begin(); scope_it != scopesets.end();
51 ++scope_it) {
52 keys.push_back(
53 extensions::ExtensionTokenKey(*extension_it, *user_it, *scope_it));
58 // keys should not be less than themselves
59 for (ExtensionTokenKeyIterator it = keys.begin(); it != keys.end(); ++it) {
60 EXPECT_FALSE(*it < *it);
63 // comparison should establish an ordering
64 std::sort(keys.begin(), keys.end());
65 for (ExtensionTokenKeyIterator it1 = keys.begin(); it1 != keys.end(); ++it1) {
66 ExtensionTokenKeyIterator it2 = it1;
67 for (++it2; it2 != keys.end(); ++it2) {
68 EXPECT_LT(*it1, *it2);
69 EXPECT_FALSE(it2 < it1);