michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // This file contains unit tests for the sid class. michael@0: michael@0: #define _ATL_NO_EXCEPTIONS michael@0: #include michael@0: #include michael@0: michael@0: #include "sandbox/win/src/sid.h" michael@0: #include "testing/gtest/include/gtest/gtest.h" michael@0: michael@0: namespace sandbox { michael@0: michael@0: // Calls ::EqualSid. This function exists only to simplify the calls to michael@0: // ::EqualSid by removing the need to cast the input params. michael@0: BOOL EqualSid(const SID *sid1, const SID *sid2) { michael@0: return ::EqualSid(const_cast(sid1), const_cast(sid2)); michael@0: } michael@0: michael@0: // Tests the creation if a Sid michael@0: TEST(SidTest, Constructors) { michael@0: ATL::CSid sid_world = ATL::Sids::World(); michael@0: SID *sid_world_pointer = const_cast(sid_world.GetPSID()); michael@0: michael@0: // Check the SID* constructor michael@0: Sid sid_sid_star(sid_world_pointer); michael@0: ASSERT_TRUE(EqualSid(sid_world_pointer, sid_sid_star.GetPSID())); michael@0: michael@0: // Check the copy constructor michael@0: Sid sid_copy(sid_sid_star); michael@0: ASSERT_TRUE(EqualSid(sid_world_pointer, sid_copy.GetPSID())); michael@0: michael@0: // Note that the WELL_KNOWN_SID_TYPE constructor is tested in the GetPSID michael@0: // test. michael@0: } michael@0: michael@0: // Tests the method GetPSID michael@0: TEST(SidTest, GetPSID) { michael@0: // Check for non-null result; michael@0: ASSERT_NE(static_cast(NULL), Sid(::WinLocalSid).GetPSID()); michael@0: ASSERT_NE(static_cast(NULL), Sid(::WinCreatorOwnerSid).GetPSID()); michael@0: ASSERT_NE(static_cast(NULL), Sid(::WinBatchSid).GetPSID()); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinNullSid).GetPSID(), michael@0: ATL::Sids::Null().GetPSID())); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinWorldSid).GetPSID(), michael@0: ATL::Sids::World().GetPSID())); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinDialupSid).GetPSID(), michael@0: ATL::Sids::Dialup().GetPSID())); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinNetworkSid).GetPSID(), michael@0: ATL::Sids::Network().GetPSID())); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinBuiltinAdministratorsSid).GetPSID(), michael@0: ATL::Sids::Admins().GetPSID())); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinBuiltinUsersSid).GetPSID(), michael@0: ATL::Sids::Users().GetPSID())); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinBuiltinGuestsSid).GetPSID(), michael@0: ATL::Sids::Guests().GetPSID())); michael@0: michael@0: ASSERT_TRUE(EqualSid(Sid(::WinProxySid).GetPSID(), michael@0: ATL::Sids::Proxy().GetPSID())); michael@0: } michael@0: michael@0: } // namespace sandbox