OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/debug/trace_event_unittest.h" | 5 #include "base/debug/trace_event_unittest.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 TraceLog::TraceOptionsFromString("record-until-full")); | 1670 TraceLog::TraceOptionsFromString("record-until-full")); |
1671 EXPECT_EQ(TraceLog::RECORD_CONTINUOUSLY, | 1671 EXPECT_EQ(TraceLog::RECORD_CONTINUOUSLY, |
1672 TraceLog::TraceOptionsFromString("record-continuously")); | 1672 TraceLog::TraceOptionsFromString("record-continuously")); |
1673 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL | TraceLog::ENABLE_SAMPLING, | 1673 EXPECT_EQ(TraceLog::RECORD_UNTIL_FULL | TraceLog::ENABLE_SAMPLING, |
1674 TraceLog::TraceOptionsFromString("enable-sampling")); | 1674 TraceLog::TraceOptionsFromString("enable-sampling")); |
1675 EXPECT_EQ(TraceLog::RECORD_CONTINUOUSLY | TraceLog::ENABLE_SAMPLING, | 1675 EXPECT_EQ(TraceLog::RECORD_CONTINUOUSLY | TraceLog::ENABLE_SAMPLING, |
1676 TraceLog::TraceOptionsFromString( | 1676 TraceLog::TraceOptionsFromString( |
1677 "record-continuously,enable-sampling")); | 1677 "record-continuously,enable-sampling")); |
1678 } | 1678 } |
1679 | 1679 |
1680 // Not supported in split dll build. http://crbug.com/256965 | |
1681 #if !defined(CHROME_SPLIT_DLL) | |
1682 TEST_F(TraceEventTestFixture, TraceSampling) { | 1680 TEST_F(TraceEventTestFixture, TraceSampling) { |
1683 event_watch_notification_ = 0; | 1681 event_watch_notification_ = 0; |
1684 TraceLog::GetInstance()->SetEnabled( | 1682 TraceLog::GetInstance()->SetEnabled( |
1685 CategoryFilter("*"), | 1683 CategoryFilter("*"), |
1686 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | | 1684 TraceLog::Options(TraceLog::RECORD_UNTIL_FULL | |
1687 TraceLog::ENABLE_SAMPLING)); | 1685 TraceLog::ENABLE_SAMPLING)); |
1688 | 1686 |
1689 WaitableEvent* sampled = new WaitableEvent(false, false); | 1687 WaitableEvent* sampled = new WaitableEvent(false, false); |
1690 TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(sampled); | 1688 TraceLog::GetInstance()->InstallWaitableEventForSamplingTesting(sampled); |
1691 | 1689 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA"); | 1729 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "AAA"); |
1732 TRACE_EVENT_SET_SAMPLING_STATE("DDD", "name"); | 1730 TRACE_EVENT_SET_SAMPLING_STATE("DDD", "name"); |
1733 sampled->Wait(); | 1731 sampled->Wait(); |
1734 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); | 1732 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); |
1735 } | 1733 } |
1736 sampled->Wait(); | 1734 sampled->Wait(); |
1737 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); | 1735 EXPECT_STREQ(TRACE_EVENT_GET_SAMPLING_STATE(), "DDD"); |
1738 | 1736 |
1739 EndTraceAndFlush(); | 1737 EndTraceAndFlush(); |
1740 } | 1738 } |
1741 #endif // !CHROME_SPLIT_DLL | |
1742 | 1739 |
1743 class MyData : public base::debug::ConvertableToTraceFormat { | 1740 class MyData : public base::debug::ConvertableToTraceFormat { |
1744 public: | 1741 public: |
1745 MyData() {} | 1742 MyData() {} |
1746 virtual ~MyData() {} | 1743 virtual ~MyData() {} |
1747 | 1744 |
1748 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { | 1745 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE { |
1749 out->append("{\"foo\":1}"); | 1746 out->append("{\"foo\":1}"); |
1750 } | 1747 } |
1751 | 1748 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( | 2015 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
2019 " bad_category ")); | 2016 " bad_category ")); |
2020 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( | 2017 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
2021 "")); | 2018 "")); |
2022 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( | 2019 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( |
2023 "good_category")); | 2020 "good_category")); |
2024 } | 2021 } |
2025 | 2022 |
2026 } // namespace debug | 2023 } // namespace debug |
2027 } // namespace base | 2024 } // namespace base |
OLD | NEW |