1/*
2 *  Copyright 2010 The WebRTC Project Authors. All rights reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/base/gunit.h"
12#include "webrtc/base/winfirewall.h"
13
14#include <objbase.h>
15
16namespace rtc {
17
18TEST(WinFirewallTest, ReadStatus) {
19  ::CoInitialize(NULL);
20  WinFirewall fw;
21  HRESULT hr;
22  bool authorized;
23
24  EXPECT_FALSE(fw.QueryAuthorized("bogus.exe", &authorized));
25  EXPECT_TRUE(fw.Initialize(&hr));
26  EXPECT_EQ(S_OK, hr);
27
28  EXPECT_TRUE(fw.QueryAuthorized("bogus.exe", &authorized));
29
30  // Unless we mock out INetFwMgr we can't really have an expectation either way
31  // about whether we're authorized.  It will depend on the settings of the
32  // machine running the test.  Same goes for AddApplication.
33
34  fw.Shutdown();
35  EXPECT_FALSE(fw.QueryAuthorized("bogus.exe", &authorized));
36
37  ::CoUninitialize();
38}
39
40}  // namespace rtc
41