Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Side by Side Diff: statsreport/aggregator-win32_unittest.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « statsreport/aggregator-win32_unittest.h ('k') | statsreport/aggregator_unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2006-2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15 //
16 // Implementation of Win32 metrics aggregator.
17 #include "aggregator-win32.h"
18 #include "aggregator-win32_unittest.h"
19 #include "aggregator_unittest.h"
20 #include "omaha/third_party/gtest/include/gtest/gtest.h"
21
22 using namespace stats_report;
23
24 #define APP_NAME_STRING L"aggregator-win32_unittest"
25 #define PREFIX_KEY_STRING L"Software\\" _T(SHORT_COMPANY_NAME_ANSI) L"\\"
26 #define SUFFIX_KEY_STRING L"\\UsageStats\\Daily"
27 #define ROOT_KEY_STRING PREFIX_KEY_STRING APP_NAME_STRING
28 #define KEY_STRING ROOT_KEY_STRING SUFFIX_KEY_STRING
29
30 const wchar_t MetricsAggregatorWin32Test::kAppName[] = APP_NAME_STRING;
31 const wchar_t MetricsAggregatorWin32Test::kRootKeyName[] = ROOT_KEY_STRING;
32 const wchar_t MetricsAggregatorWin32Test::kCountsKeyName[] =
33 KEY_STRING L"\\Counts";
34 const wchar_t MetricsAggregatorWin32Test::kTimingsKeyName[] =
35 KEY_STRING L"\\Timings";
36 const wchar_t MetricsAggregatorWin32Test::kIntegersKeyName[] =
37 KEY_STRING L"\\Integers";
38 const wchar_t MetricsAggregatorWin32Test::kBoolsKeyName[] =
39 KEY_STRING L"\\Booleans";
40
41
42 #define EXPECT_REGVAL_EQ(value, key_name, value_name) do { \
43 char buf[sizeof(value)]; \
44 ULONG len = sizeof(buf); \
45 CRegKey key; \
46 ASSERT_EQ(ERROR_SUCCESS, key.Open(HKEY_CURRENT_USER, key_name)); \
47 EXPECT_EQ(ERROR_SUCCESS, key.QueryBinaryValue(value_name, buf, &len)); \
48 EXPECT_EQ(sizeof(buf), len); \
49 EXPECT_EQ(0, memcmp(&value, buf, sizeof(buf))); \
50 } while(0)
51
52 TEST_F(MetricsAggregatorWin32Test, AggregateWin32) {
53 MetricsAggregatorWin32 agg(coll_, kAppName);
54
55 EXPECT_TRUE(agg.AggregateMetrics());
56 AddStats();
57 EXPECT_TRUE(agg.AggregateMetrics());
58
59 {
60 int64 one = 1, two = 2;
61 EXPECT_REGVAL_EQ(one, kCountsKeyName, L"c1");
62 EXPECT_REGVAL_EQ(two, kCountsKeyName, L"c2");
63
64 TimingMetric::TimingData data1 = { 2, 0, 1500, 500, 1000 };
65 TimingMetric::TimingData data2 = { 2, 0, 2030, 30, 2000 };
66 EXPECT_REGVAL_EQ(data1, kTimingsKeyName, L"t1");
67 EXPECT_REGVAL_EQ(data2, kTimingsKeyName, L"t2");
68
69 EXPECT_REGVAL_EQ(one, kIntegersKeyName, L"i1");
70 EXPECT_REGVAL_EQ(two, kIntegersKeyName, L"i2");
71
72 int32 bool_true = 1, bool_false = 0;
73 EXPECT_REGVAL_EQ(bool_true, kBoolsKeyName, L"b1");
74 EXPECT_REGVAL_EQ(bool_false, kBoolsKeyName, L"b2");
75 }
76
77 AddStats();
78 EXPECT_TRUE(agg.AggregateMetrics());
79
80 {
81 int64 two = 2, four = 4;
82 EXPECT_REGVAL_EQ(two, kCountsKeyName, L"c1");
83 EXPECT_REGVAL_EQ(four, kCountsKeyName, L"c2");
84
85 TimingMetric::TimingData data1 = { 4, 0, 3000, 500, 1000 };
86 TimingMetric::TimingData data2 = { 4, 0, 4060, 30, 2000 };
87 EXPECT_REGVAL_EQ(data1, kTimingsKeyName, L"t1");
88 EXPECT_REGVAL_EQ(data2, kTimingsKeyName, L"t2");
89
90 int64 one = 1;
91 EXPECT_REGVAL_EQ(one, kIntegersKeyName, L"i1");
92 EXPECT_REGVAL_EQ(two, kIntegersKeyName, L"i2");
93
94 int32 bool_true = 1, bool_false = 0;
95 EXPECT_REGVAL_EQ(bool_true, kBoolsKeyName, L"b1");
96 EXPECT_REGVAL_EQ(bool_false, kBoolsKeyName, L"b2");
97 }
98 }
OLDNEW
« no previous file with comments | « statsreport/aggregator-win32_unittest.h ('k') | statsreport/aggregator_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698