OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Unit tests for event trace controller. | 5 // Unit tests for event trace controller. |
6 #include "base/event_trace_controller_win.h" | 6 #include "base/event_trace_controller_win.h" |
7 #include "base/event_trace_provider_win.h" | 7 #include "base/event_trace_provider_win.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/scoped_handle.h" | 11 #include "base/scoped_handle.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 TEST(EtwTraceTest, Cleanup) { | 56 TEST(EtwTraceTest, Cleanup) { |
57 // Clean up potential leftover sessions from previous unsuccessful runs. | 57 // Clean up potential leftover sessions from previous unsuccessful runs. |
58 EtwTraceController::Stop(kTestSessionName, NULL); | 58 EtwTraceController::Stop(kTestSessionName, NULL); |
59 } | 59 } |
60 | 60 |
61 TEST(EtwTracePropertiesTest, Initialization) { | 61 TEST(EtwTracePropertiesTest, Initialization) { |
62 EtwTraceProperties prop; | 62 EtwTraceProperties prop; |
63 | 63 |
64 EVENT_TRACE_PROPERTIES* p = prop.get(); | 64 EVENT_TRACE_PROPERTIES* p = prop.get(); |
65 EXPECT_NE(0u, p->Wnode.BufferSize); | 65 EXPECT_NE(0, p->Wnode.BufferSize); |
66 EXPECT_EQ(0u, p->Wnode.ProviderId); | 66 EXPECT_EQ(0, p->Wnode.ProviderId); |
67 EXPECT_EQ(0u, p->Wnode.HistoricalContext); | 67 EXPECT_EQ(0, p->Wnode.HistoricalContext); |
68 | 68 |
69 EXPECT_TRUE(kGuidNull == p->Wnode.Guid); | 69 EXPECT_TRUE(kGuidNull == p->Wnode.Guid); |
70 EXPECT_EQ(0, p->Wnode.ClientContext); | 70 EXPECT_EQ(0, p->Wnode.ClientContext); |
71 EXPECT_EQ(WNODE_FLAG_TRACED_GUID, p->Wnode.Flags); | 71 EXPECT_EQ(WNODE_FLAG_TRACED_GUID, p->Wnode.Flags); |
72 | 72 |
73 EXPECT_EQ(0, p->BufferSize); | 73 EXPECT_EQ(0, p->BufferSize); |
74 EXPECT_EQ(0, p->MinimumBuffers); | 74 EXPECT_EQ(0, p->MinimumBuffers); |
75 EXPECT_EQ(0, p->MaximumBuffers); | 75 EXPECT_EQ(0, p->MaximumBuffers); |
76 EXPECT_EQ(0, p->MaximumFileSize); | 76 EXPECT_EQ(0, p->MaximumFileSize); |
77 EXPECT_EQ(0, p->LogFileMode); | 77 EXPECT_EQ(0, p->LogFileMode); |
78 EXPECT_EQ(0, p->FlushTimer); | 78 EXPECT_EQ(0, p->FlushTimer); |
79 EXPECT_EQ(0, p->EnableFlags); | 79 EXPECT_EQ(0, p->EnableFlags); |
80 EXPECT_EQ(0, p->AgeLimit); | 80 EXPECT_EQ(0, p->AgeLimit); |
81 | 81 |
82 EXPECT_EQ(0, p->NumberOfBuffers); | 82 EXPECT_EQ(0, p->NumberOfBuffers); |
83 EXPECT_EQ(0, p->FreeBuffers); | 83 EXPECT_EQ(0, p->FreeBuffers); |
84 EXPECT_EQ(0, p->EventsLost); | 84 EXPECT_EQ(0, p->EventsLost); |
85 EXPECT_EQ(0, p->BuffersWritten); | 85 EXPECT_EQ(0, p->BuffersWritten); |
86 EXPECT_EQ(0, p->LogBuffersLost); | 86 EXPECT_EQ(0, p->LogBuffersLost); |
87 EXPECT_EQ(0, p->RealTimeBuffersLost); | 87 EXPECT_EQ(0, p->RealTimeBuffersLost); |
88 EXPECT_EQ(0, p->LoggerThreadId); | 88 EXPECT_EQ(0, p->LoggerThreadId); |
89 EXPECT_NE(0u, p->LogFileNameOffset); | 89 EXPECT_NE(0, p->LogFileNameOffset); |
90 EXPECT_NE(0u, p->LoggerNameOffset); | 90 EXPECT_NE(0, p->LoggerNameOffset); |
91 } | 91 } |
92 | 92 |
93 TEST(EtwTracePropertiesTest, Strings) { | 93 TEST(EtwTracePropertiesTest, Strings) { |
94 EtwTraceProperties prop; | 94 EtwTraceProperties prop; |
95 | 95 |
96 ASSERT_STREQ(L"", prop.GetLoggerFileName()); | 96 ASSERT_STREQ(L"", prop.GetLoggerFileName()); |
97 ASSERT_STREQ(L"", prop.GetLoggerName()); | 97 ASSERT_STREQ(L"", prop.GetLoggerName()); |
98 | 98 |
99 std::wstring name(1023, L'A'); | 99 std::wstring name(1023, L'A'); |
100 ASSERT_HRESULT_SUCCEEDED(prop.SetLoggerFileName(name.c_str())); | 100 ASSERT_HRESULT_SUCCEEDED(prop.SetLoggerFileName(name.c_str())); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); | 194 EXPECT_EQ(kTestProviderFlags, provider.enable_flags()); |
195 | 195 |
196 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); | 196 EXPECT_HRESULT_SUCCEEDED(controller.Stop(NULL)); |
197 | 197 |
198 provider.WaitForCallback(); | 198 provider.WaitForCallback(); |
199 | 199 |
200 // Session should have wound down. | 200 // Session should have wound down. |
201 EXPECT_EQ(0, provider.enable_level()); | 201 EXPECT_EQ(0, provider.enable_level()); |
202 EXPECT_EQ(0, provider.enable_flags()); | 202 EXPECT_EQ(0, provider.enable_flags()); |
203 } | 203 } |
OLD | NEW |