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

Unified Diff: base/callback_helpers_unittest.cc

Issue 2513363003: repro for crbug.com/663886
Patch Set: Created 4 years, 1 month 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/callback_helpers.cc ('k') | base/callback_internal.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_helpers_unittest.cc
diff --git a/base/callback_helpers_unittest.cc b/base/callback_helpers_unittest.cc
index 82839963795fcf39e657a3d9b1cd35df5b2ae215..8cc8d3dda692367d30e09cf98bcf4715fb56a465 100644
--- a/base/callback_helpers_unittest.cc
+++ b/base/callback_helpers_unittest.cc
@@ -1,94 +1,13 @@
-// Copyright 2013 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/callback_helpers.h"
-
-#include "base/bind.h"
-#include "base/callback.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-void Increment(int* value) {
+__attribute__((visibility("default"))) void Increment(int* value) {
(*value)++;
}
-TEST(CallbackHelpersTest, TestScopedClosureRunnerExitScope) {
- int run_count = 0;
- {
- base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count));
- EXPECT_EQ(0, run_count);
- }
- EXPECT_EQ(1, run_count);
-}
-
-TEST(CallbackHelpersTest, TestScopedClosureRunnerRelease) {
- int run_count = 0;
- base::Closure c;
- {
- base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count));
- c = runner.Release();
- EXPECT_EQ(0, run_count);
- }
- EXPECT_EQ(0, run_count);
- c.Run();
- EXPECT_EQ(1, run_count);
-}
-
-TEST(CallbackHelpersTest, TestScopedClosureRunnerReplaceClosure) {
- int run_count_1 = 0;
- int run_count_2 = 0;
- {
- base::ScopedClosureRunner runner;
- runner.ReplaceClosure(base::Bind(&Increment, &run_count_1));
- runner.ReplaceClosure(base::Bind(&Increment, &run_count_2));
- EXPECT_EQ(0, run_count_1);
- EXPECT_EQ(0, run_count_2);
- }
- EXPECT_EQ(0, run_count_1);
- EXPECT_EQ(1, run_count_2);
-}
-
-TEST(CallbackHelpersTest, TestScopedClosureRunnerRunAndReset) {
- int run_count_3 = 0;
- {
- base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count_3));
- EXPECT_EQ(0, run_count_3);
- runner.RunAndReset();
- EXPECT_EQ(1, run_count_3);
- }
- EXPECT_EQ(1, run_count_3);
-}
-
-TEST(CallbackHelpersTest, TestScopedClosureRunnerMoveConstructor) {
- int run_count = 0;
- {
- std::unique_ptr<base::ScopedClosureRunner> runner(
- new base::ScopedClosureRunner(base::Bind(&Increment, &run_count)));
- base::ScopedClosureRunner runner2(std::move(*runner));
- runner.reset();
- EXPECT_EQ(0, run_count);
- }
- EXPECT_EQ(1, run_count);
-}
-
-TEST(CallbackHelpersTest, TestScopedClosureRunnerMoveAssignment) {
- int run_count_1 = 0;
- int run_count_2 = 0;
- {
- base::ScopedClosureRunner runner(base::Bind(&Increment, &run_count_1));
- {
- base::ScopedClosureRunner runner2(base::Bind(&Increment, &run_count_2));
- runner = std::move(runner2);
- EXPECT_EQ(0, run_count_1);
- EXPECT_EQ(0, run_count_2);
- }
- EXPECT_EQ(0, run_count_1);
- EXPECT_EQ(0, run_count_2);
- }
- EXPECT_EQ(0, run_count_1);
- EXPECT_EQ(1, run_count_2);
-}
+class Listener {
+ public:
+ Listener() : total_(0) {}
+ void IncrementTotal() { total_++; }
+ int total_;
+};
-} // namespace
+void(Listener::*secret(void (Listener::*memptr)()))() { return memptr; }
+Listener* secret(Listener* l) { return l; }
« no previous file with comments | « base/callback_helpers.cc ('k') | base/callback_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698