diff options
author | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-21 21:27:45 +0000 |
---|---|---|
committer | evanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-21 21:27:45 +0000 |
commit | 778cb2f49af834951ab17e95c9143c313e5bf1a2 (patch) | |
tree | 8d3c27c95cb8dcd0fd43576fe2a5d85793c11279 /base/stats_table_unittest.cc | |
parent | a0dde12f2e4f92f1a59885c45cfecd10dbfdfdfd (diff) | |
download | chromium_src-778cb2f49af834951ab17e95c9143c313e5bf1a2.zip chromium_src-778cb2f49af834951ab17e95c9143c313e5bf1a2.tar.gz chromium_src-778cb2f49af834951ab17e95c9143c313e5bf1a2.tar.bz2 |
Rollback "Remove use of wide characters in stats table identifiers."
This reverts commit r5847.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/stats_table_unittest.cc')
-rw-r--r-- | base/stats_table_unittest.cc | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/base/stats_table_unittest.cc b/base/stats_table_unittest.cc index 59b1215..68a07ac 100644 --- a/base/stats_table_unittest.cc +++ b/base/stats_table_unittest.cc @@ -24,27 +24,27 @@ class StatsTableTest : public MultiProcessTest { // Open a StatsTable and verify that we can write to each of the // locations in the table. TEST_F(StatsTableTest, VerifySlots) { - const std::string kTableName = "VerifySlotsStatTable"; + const std::wstring kTableName = L"VerifySlotsStatTable"; const int kMaxThreads = 1; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); // Register a single thread. - std::string thread_name = "mainThread"; + std::wstring thread_name = L"mainThread"; int slot_id = table.RegisterThread(thread_name); EXPECT_TRUE(slot_id); // Fill up the table with counters. - std::string counter_base_name = "counter"; + std::wstring counter_base_name = L"counter"; for (int index=0; index < kMaxCounter; index++) { - std::string counter_name = counter_base_name; - StringAppendF(&counter_name, "counter.ctr%d", index); + std::wstring counter_name = counter_base_name; + StringAppendF(&counter_name, L"counter.ctr%d", index); int counter_id = table.FindCounter(counter_name); EXPECT_GT(counter_id, 0); } // Try to allocate an additional thread. Verify it fails. - slot_id = table.RegisterThread("too many threads"); + slot_id = table.RegisterThread(L"too many threads"); EXPECT_EQ(slot_id, 0); // Try to allocate an additional counter. Verify it fails. @@ -53,16 +53,16 @@ TEST_F(StatsTableTest, VerifySlots) { } // CounterZero will continually be set to 0. -const std::string kCounterZero = "CounterZero"; +const std::wstring kCounterZero = L"CounterZero"; // Counter1313 will continually be set to 1313. -const std::string kCounter1313 = "Counter1313"; +const std::wstring kCounter1313 = L"Counter1313"; // CounterIncrement will be incremented each time. -const std::string kCounterIncrement = "CounterIncrement"; +const std::wstring kCounterIncrement = L"CounterIncrement"; // CounterDecrement will be decremented each time. -const std::string kCounterDecrement = "CounterDecrement"; +const std::wstring kCounterDecrement = L"CounterDecrement"; // CounterMixed will be incremented by odd numbered threads and // decremented by even threads. -const std::string kCounterMixed = "CounterMixed"; +const std::wstring kCounterMixed = L"CounterMixed"; // The number of thread loops that we will do. const int kThreadLoops = 1000; @@ -101,7 +101,7 @@ void StatsTableThread::Run() { // Create a few threads and have them poke on their counters. TEST_F(StatsTableTest, MultipleThreads) { // Create a stats table. - const std::string kTableName = "MultipleThreadStatTable"; + const std::wstring kTableName = L"MultipleThreadStatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); @@ -133,25 +133,25 @@ TEST_F(StatsTableTest, MultipleThreads) { StatsCounter mixed_counter(kCounterMixed); // Verify the various counters are correct. - std::string name; - name = "c:" + kCounterZero; + std::wstring name; + name = L"c:" + kCounterZero; EXPECT_EQ(0, table.GetCounterValue(name)); - name = "c:" + kCounter1313; + name = L"c:" + kCounter1313; EXPECT_EQ(1313 * kMaxThreads, table.GetCounterValue(name)); - name = "c:" + kCounterIncrement; + name = L"c:" + kCounterIncrement; EXPECT_EQ(kMaxThreads * kThreadLoops, table.GetCounterValue(name)); - name = "c:" + kCounterDecrement; + name = L"c:" + kCounterDecrement; EXPECT_EQ(-kMaxThreads * kThreadLoops, table.GetCounterValue(name)); - name = "c:" + kCounterMixed; + name = L"c:" + kCounterMixed; EXPECT_EQ((kMaxThreads % 2) * kThreadLoops, table.GetCounterValue(name)); EXPECT_EQ(0, table.CountThreadsRegistered()); } -const std::string kTableName = "MultipleProcessStatTable"; +const std::wstring kTableName = L"MultipleProcessStatTable"; MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { // Each process will open the shared memory and set counters @@ -177,7 +177,7 @@ MULTIPROCESS_TEST_MAIN(StatsTableMultipleProcessMain) { // Create a few processes and have them poke on their counters. TEST_F(StatsTableTest, MultipleProcesses) { // Create a stats table. - const std::string kTableName = "MultipleProcessStatTable"; + const std::wstring kTableName = L"MultipleProcessStatTable"; const int kMaxProcs = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxProcs, kMaxCounter); @@ -207,16 +207,16 @@ TEST_F(StatsTableTest, MultipleProcesses) { StatsCounter decrement_counter(kCounterDecrement); // Verify the various counters are correct. - std::string name; - name = "c:" + kCounterZero; + std::wstring name; + name = L"c:" + kCounterZero; EXPECT_EQ(0, table.GetCounterValue(name)); - name = "c:" + kCounter1313; + name = L"c:" + kCounter1313; EXPECT_EQ(1313 * kMaxProcs, table.GetCounterValue(name)); - name = "c:" + kCounterIncrement; + name = L"c:" + kCounterIncrement; EXPECT_EQ(kMaxProcs * kThreadLoops, table.GetCounterValue(name)); - name = "c:" + kCounterDecrement; + name = L"c:" + kCounterDecrement; EXPECT_EQ(-kMaxProcs * kThreadLoops, table.GetCounterValue(name)); EXPECT_EQ(0, table.CountThreadsRegistered()); @@ -224,7 +224,7 @@ TEST_F(StatsTableTest, MultipleProcesses) { class MockStatsCounter : public StatsCounter { public: - MockStatsCounter(const std::string& name) + MockStatsCounter(const std::wstring& name) : StatsCounter(name) {} int* Pointer() { return GetPtr(); } }; @@ -232,50 +232,50 @@ class MockStatsCounter : public StatsCounter { // Test some basic StatsCounter operations TEST_F(StatsTableTest, StatsCounter) { // Create a stats table. - const std::string kTableName = "StatTable"; + const std::wstring kTableName = L"StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - MockStatsCounter foo("foo"); + MockStatsCounter foo(L"foo"); // Test initial state. EXPECT_TRUE(foo.Enabled()); EXPECT_NE(foo.Pointer(), static_cast<int*>(0)); - EXPECT_EQ(0, table.GetCounterValue("c:foo")); + EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); EXPECT_EQ(0, *(foo.Pointer())); // Test Increment. while(*(foo.Pointer()) < 123) foo.Increment(); - EXPECT_EQ(123, table.GetCounterValue("c:foo")); + EXPECT_EQ(123, table.GetCounterValue(L"c:foo")); foo.Add(0); - EXPECT_EQ(123, table.GetCounterValue("c:foo")); + EXPECT_EQ(123, table.GetCounterValue(L"c:foo")); foo.Add(-1); - EXPECT_EQ(122, table.GetCounterValue("c:foo")); + EXPECT_EQ(122, table.GetCounterValue(L"c:foo")); // Test Set. foo.Set(0); - EXPECT_EQ(0, table.GetCounterValue("c:foo")); + EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); foo.Set(100); - EXPECT_EQ(100, table.GetCounterValue("c:foo")); + EXPECT_EQ(100, table.GetCounterValue(L"c:foo")); foo.Set(-1); - EXPECT_EQ(-1, table.GetCounterValue("c:foo")); + EXPECT_EQ(-1, table.GetCounterValue(L"c:foo")); foo.Set(0); - EXPECT_EQ(0, table.GetCounterValue("c:foo")); + EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); // Test Decrement. foo.Decrement(1); - EXPECT_EQ(-1, table.GetCounterValue("c:foo")); + EXPECT_EQ(-1, table.GetCounterValue(L"c:foo")); foo.Decrement(0); - EXPECT_EQ(-1, table.GetCounterValue("c:foo")); + EXPECT_EQ(-1, table.GetCounterValue(L"c:foo")); foo.Decrement(-1); - EXPECT_EQ(0, table.GetCounterValue("c:foo")); + EXPECT_EQ(0, table.GetCounterValue(L"c:foo")); } class MockStatsCounterTimer : public StatsCounterTimer { public: - MockStatsCounterTimer(const std::string& name) + MockStatsCounterTimer(const std::wstring& name) : StatsCounterTimer(name) {} TimeTicks start_time() { return start_time_; } @@ -285,13 +285,13 @@ class MockStatsCounterTimer : public StatsCounterTimer { // Test some basic StatsCounterTimer operations TEST_F(StatsTableTest, StatsCounterTimer) { // Create a stats table. - const std::string kTableName = "StatTable"; + const std::wstring kTableName = L"StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - MockStatsCounterTimer bar("bar"); + MockStatsCounterTimer bar(L"bar"); // Test initial state. EXPECT_FALSE(bar.Running()); @@ -302,62 +302,62 @@ TEST_F(StatsTableTest, StatsCounterTimer) { bar.Start(); PlatformThread::Sleep(500); bar.Stop(); - EXPECT_LE(500, table.GetCounterValue("t:bar")); + EXPECT_LE(500, table.GetCounterValue(L"t:bar")); // Verify that timing again is additive. bar.Start(); PlatformThread::Sleep(500); bar.Stop(); - EXPECT_LE(1000, table.GetCounterValue("t:bar")); + EXPECT_LE(1000, table.GetCounterValue(L"t:bar")); } // Test some basic StatsRate operations TEST_F(StatsTableTest, StatsRate) { // Create a stats table. - const std::string kTableName = "StatTable"; + const std::wstring kTableName = L"StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - StatsRate baz("baz"); + StatsRate baz(L"baz"); // Test initial state. EXPECT_FALSE(baz.Running()); - EXPECT_EQ(0, table.GetCounterValue("c:baz")); - EXPECT_EQ(0, table.GetCounterValue("t:baz")); + EXPECT_EQ(0, table.GetCounterValue(L"c:baz")); + EXPECT_EQ(0, table.GetCounterValue(L"t:baz")); // Do some timing. baz.Start(); PlatformThread::Sleep(500); baz.Stop(); - EXPECT_EQ(1, table.GetCounterValue("c:baz")); - EXPECT_LE(500, table.GetCounterValue("t:baz")); + EXPECT_EQ(1, table.GetCounterValue(L"c:baz")); + EXPECT_LE(500, table.GetCounterValue(L"t:baz")); // Verify that timing again is additive. baz.Start(); PlatformThread::Sleep(500); baz.Stop(); - EXPECT_EQ(2, table.GetCounterValue("c:baz")); - EXPECT_LE(1000, table.GetCounterValue("t:baz")); + EXPECT_EQ(2, table.GetCounterValue(L"c:baz")); + EXPECT_LE(1000, table.GetCounterValue(L"t:baz")); } // Test some basic StatsScope operations TEST_F(StatsTableTest, StatsScope) { // Create a stats table. - const std::string kTableName = "StatTable"; + const std::wstring kTableName = L"StatTable"; const int kMaxThreads = 20; const int kMaxCounter = 5; StatsTable table(kTableName, kMaxThreads, kMaxCounter); StatsTable::set_current(&table); - StatsCounterTimer foo("foo"); - StatsRate bar("bar"); + StatsCounterTimer foo(L"foo"); + StatsRate bar(L"bar"); // Test initial state. - EXPECT_EQ(0, table.GetCounterValue("t:foo")); - EXPECT_EQ(0, table.GetCounterValue("t:bar")); - EXPECT_EQ(0, table.GetCounterValue("c:bar")); + EXPECT_EQ(0, table.GetCounterValue(L"t:foo")); + EXPECT_EQ(0, table.GetCounterValue(L"t:bar")); + EXPECT_EQ(0, table.GetCounterValue(L"c:bar")); // Try a scope. { @@ -365,9 +365,9 @@ TEST_F(StatsTableTest, StatsScope) { StatsScope<StatsRate> timer2(bar); PlatformThread::Sleep(500); } - EXPECT_LE(500, table.GetCounterValue("t:foo")); - EXPECT_LE(500, table.GetCounterValue("t:bar")); - EXPECT_EQ(1, table.GetCounterValue("c:bar")); + EXPECT_LE(500, table.GetCounterValue(L"t:foo")); + EXPECT_LE(500, table.GetCounterValue(L"t:bar")); + EXPECT_EQ(1, table.GetCounterValue(L"c:bar")); // Try a second scope. { @@ -375,9 +375,9 @@ TEST_F(StatsTableTest, StatsScope) { StatsScope<StatsRate> timer2(bar); PlatformThread::Sleep(500); } - EXPECT_LE(1000, table.GetCounterValue("t:foo")); - EXPECT_LE(1000, table.GetCounterValue("t:bar")); - EXPECT_EQ(2, table.GetCounterValue("c:bar")); + EXPECT_LE(1000, table.GetCounterValue(L"t:foo")); + EXPECT_LE(1000, table.GetCounterValue(L"t:bar")); + EXPECT_EQ(2, table.GetCounterValue(L"c:bar")); } } // namespace base |