blob: d24c843c194d4c40f8daa3120d3acce560a2983c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <Foundation/Foundation.h>
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/sys_string_conversions.h"
#include "chrome/installer/util/google_update_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
namespace google_update {
bool GetCollectStatsConsentFromDictionary(NSDictionary* dict);
} // namespace google_update
class GoogleUpdateTest : public PlatformTest {
};
TEST_F(GoogleUpdateTest, StatsConstent) {
using google_update::GetCollectStatsConsentFromDictionary;
// Stats are off by default.
NSDictionary* empty_dict = [NSDictionary dictionary];
ASSERT_FALSE(GetCollectStatsConsentFromDictionary(empty_dict));
NSString* collect_stats_key = base::SysWideToNSString(
google_update::kRegUsageStatsField);
// Stats reporting is ON.
NSNumber* stats_enabled = [NSNumber numberWithBool:YES];
NSDictionary* enabled_dict = [NSDictionary
dictionaryWithObject:stats_enabled
forKey:collect_stats_key];
ASSERT_TRUE(GetCollectStatsConsentFromDictionary(enabled_dict));
// Stats reporting is OFF.
NSNumber* stats_disabled = [NSNumber numberWithBool:NO];
NSDictionary* disabled_dict = [NSDictionary
dictionaryWithObject:stats_disabled
forKey:collect_stats_key];
ASSERT_FALSE(GetCollectStatsConsentFromDictionary(disabled_dict));
// Check that we fail gracefully if an object of the wrong type is present.
NSDictionary* wrong_type_dict = [NSDictionary
dictionaryWithObject:empty_dict
forKey:collect_stats_key];
ASSERT_FALSE(GetCollectStatsConsentFromDictionary(wrong_type_dict));
}
|