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

Unified Diff: base/timer/mock_timer_unittest.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/timer/mock_timer.cc ('k') | base/timer/timer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/timer/mock_timer_unittest.cc
diff --git a/base/timer/mock_timer_unittest.cc b/base/timer/mock_timer_unittest.cc
deleted file mode 100644
index f6b6953648a0abed87fa888e631487b03336434c..0000000000000000000000000000000000000000
--- a/base/timer/mock_timer_unittest.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2014 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 "base/timer/mock_timer.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-void CallMeMaybe(int *number) {
- (*number)++;
-}
-
-TEST(MockTimerTest, FiresOnce) {
- int calls = 0;
- base::MockTimer timer(false, false);
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
- timer.Start(FROM_HERE, delay,
- base::Bind(&CallMeMaybe,
- base::Unretained(&calls)));
- EXPECT_EQ(delay, timer.GetCurrentDelay());
- EXPECT_TRUE(timer.IsRunning());
- timer.Fire();
- EXPECT_FALSE(timer.IsRunning());
- EXPECT_EQ(1, calls);
-}
-
-TEST(MockTimerTest, FiresRepeatedly) {
- int calls = 0;
- base::MockTimer timer(true, true);
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
- timer.Start(FROM_HERE, delay,
- base::Bind(&CallMeMaybe,
- base::Unretained(&calls)));
- timer.Fire();
- EXPECT_TRUE(timer.IsRunning());
- timer.Fire();
- timer.Fire();
- EXPECT_TRUE(timer.IsRunning());
- EXPECT_EQ(3, calls);
-}
-
-TEST(MockTimerTest, Stops) {
- int calls = 0;
- base::MockTimer timer(true, true);
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
- timer.Start(FROM_HERE, delay,
- base::Bind(&CallMeMaybe,
- base::Unretained(&calls)));
- EXPECT_TRUE(timer.IsRunning());
- timer.Stop();
- EXPECT_FALSE(timer.IsRunning());
-}
-
-class HasWeakPtr : public base::SupportsWeakPtr<HasWeakPtr> {
- public:
- HasWeakPtr() {}
- virtual ~HasWeakPtr() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HasWeakPtr);
-};
-
-void DoNothingWithWeakPtr(HasWeakPtr* has_weak_ptr) {
-}
-
-TEST(MockTimerTest, DoesNotRetainClosure) {
- HasWeakPtr *has_weak_ptr = new HasWeakPtr();
- base::WeakPtr<HasWeakPtr> weak_ptr(has_weak_ptr->AsWeakPtr());
- base::MockTimer timer(false, false);
- base::TimeDelta delay = base::TimeDelta::FromSeconds(2);
- ASSERT_TRUE(weak_ptr.get());
- timer.Start(FROM_HERE, delay,
- base::Bind(&DoNothingWithWeakPtr,
- base::Owned(has_weak_ptr)));
- ASSERT_TRUE(weak_ptr.get());
- timer.Fire();
- ASSERT_FALSE(weak_ptr.get());
-}
-
-} // namespace
« no previous file with comments | « base/timer/mock_timer.cc ('k') | base/timer/timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698