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

Unified Diff: chrome/browser/data_use_measurement/chrome_data_use_ascriber_service_browsertest.cc

Issue 2285903002: Framework to ascribe all network data use to a source. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 4 years, 3 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
Index: chrome/browser/data_use_measurement/chrome_data_use_ascriber_service_browsertest.cc
diff --git a/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service_browsertest.cc b/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..67902e35b2084be96a8a721fbbd4fa0111c897d0
--- /dev/null
+++ b/chrome/browser/data_use_measurement/chrome_data_use_ascriber_service_browsertest.cc
@@ -0,0 +1,59 @@
+// Copyright 2016 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 "chrome/browser/data_use_measurement/chrome_data_use_ascriber_service.h"
+
+#include <memory>
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h"
+#include "chrome/browser/io_thread.h"
+#include "chrome/test/base/in_process_browser_test.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace data_use_measurement {
+
+class ChromeDataUseAscriberServiceTest : public InProcessBrowserTest {
Lei Zhang 2016/09/08 22:04:43 Do you plan to add more test cases? As is, it may
Not at Google. Contact bengr 2016/09/09 18:37:16 Done. It was a little awkward to instantiate IOTh
+ protected:
+ void SetUpOnMainThread() override {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ChromeDataUseAscriberServiceTest::SetUpOnIOThread,
+ base::Unretained(this), new ChromeDataUseAscriberService(),
+ g_browser_process->io_thread()));
+ RunAllPendingInMessageLoop(content::BrowserThread::IO);
+ }
+
+ void SetUpOnIOThread(ChromeDataUseAscriberService* service,
+ IOThread* io_thread) {
+ io_thread->globals()->data_use_ascriber.reset(
+ new data_use_measurement::ChromeDataUseAscriber());
+ service_.reset(service);
+ }
+
+ void TearDownOnMainThread() override {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ChromeDataUseAscriberServiceTest::TearDownOnIOThread,
+ base::Unretained(this), g_browser_process->io_thread()));
+ RunAllPendingInMessageLoop(content::BrowserThread::IO);
+ }
+
+ void TearDownOnIOThread(IOThread* io_thread) {
+ io_thread->globals()->data_use_ascriber.reset();
+ }
+
+ ChromeDataUseAscriber* ascriber() { return service_->ascriber_; }
+
+ private:
+ std::unique_ptr<ChromeDataUseAscriberService> service_;
+};
+
+IN_PROC_BROWSER_TEST_F(ChromeDataUseAscriberServiceTest, Initialization) {
+ EXPECT_NE(nullptr, ascriber());
+}
+
+} // namespace data_use_measurement

Powered by Google App Engine
This is Rietveld 408576698