Add ICU message format support
[chromium-blink-merge.git] / sandbox / win / src / app_container_unittest.cc
blob4bce16a42b5b49b1fdbfcccfd02ebddf84cedaaf
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
3 // found in the LICENSE file.
5 #include "base/win/windows_version.h"
6 #include "sandbox/win/src/app_container.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace sandbox {
11 // Tests the low level AppContainer interface.
12 TEST(AppContainerTest, CreateAppContainer) {
13 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8)
14 return;
16 const wchar_t kName[] = L"Test";
17 const wchar_t kValidSid[] = L"S-1-15-2-12345-234-567-890-123-456-789";
19 EXPECT_TRUE(LookupAppContainer(kValidSid).empty());
20 EXPECT_EQ(SBOX_ERROR_GENERIC, DeleteAppContainer(kValidSid));
22 EXPECT_EQ(SBOX_ALL_OK, CreateAppContainer(kValidSid, kName));
23 EXPECT_EQ(SBOX_ERROR_GENERIC, CreateAppContainer(kValidSid, kName));
24 EXPECT_EQ(kName, LookupAppContainer(kValidSid));
25 EXPECT_EQ(SBOX_ALL_OK, DeleteAppContainer(kValidSid));
27 EXPECT_TRUE(LookupAppContainer(kValidSid).empty());
28 EXPECT_EQ(SBOX_ERROR_GENERIC, DeleteAppContainer(kValidSid));
30 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER,
31 CreateAppContainer(L"Foo", kName));
34 // Tests handling of security capabilities on the attribute list.
35 TEST(AppContainerTest, SecurityCapabilities) {
36 if (base::win::OSInfo::GetInstance()->version() < base::win::VERSION_WIN8)
37 return;
39 scoped_ptr<AppContainerAttributes> attributes(new AppContainerAttributes);
40 std::vector<base::string16> capabilities;
41 EXPECT_EQ(SBOX_ERROR_INVALID_APP_CONTAINER,
42 attributes->SetAppContainer(L"S-1-foo", capabilities));
44 EXPECT_EQ(SBOX_ALL_OK,
45 attributes->SetAppContainer(L"S-1-15-2-12345-234", capabilities));
46 EXPECT_TRUE(attributes->HasAppContainer());
48 attributes.reset(new AppContainerAttributes);
49 capabilities.push_back(L"S-1-15-3-12345678-87654321");
50 capabilities.push_back(L"S-1-15-3-1");
51 capabilities.push_back(L"S-1-15-3-2");
52 capabilities.push_back(L"S-1-15-3-3");
53 EXPECT_EQ(SBOX_ALL_OK,
54 attributes->SetAppContainer(L"S-1-15-2-1-2", capabilities));
55 EXPECT_TRUE(attributes->HasAppContainer());
58 } // namespace sandbox