Refactor ResourceRequestAllowedNotifier EULA checking into a separate class.

This paves the way for making a EulaAcceptedNotifierAndroid class.

Also enables EULA logic tests on all platforms, not just ChromeOS
(since the EULA criteria are being mocked already).

No functionality changes.

BUG=226757
TEST=Existing unit tests.

Review URL: https://chromiumcodereview.appspot.com/13620010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192915 0039d316-1c4b-4281-b951-d872f2087c98
parent fdc3493b
// Copyright (c) 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 "chrome/browser/metrics/variations/eula_accepted_notifier.h"
#include "base/logging.h"
EulaAcceptedNotifier::EulaAcceptedNotifier() : observer_(NULL) {
}
EulaAcceptedNotifier::~EulaAcceptedNotifier() {
}
void EulaAcceptedNotifier::Init(Observer* observer) {
DCHECK(!observer_ && observer);
observer_ = observer;
}
void EulaAcceptedNotifier::NotifyObserver() {
observer_->OnEulaAccepted();
}
#if !defined(OS_CHROMEOS)
// static
EulaAcceptedNotifier* EulaAcceptedNotifier::Create() {
return NULL;
}
#endif
// Copyright (c) 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.
#ifndef CHROME_BROWSER_METRICS_VARIATIONS_EULA_ACCEPTED_NOTIFIER_H_
#define CHROME_BROWSER_METRICS_VARIATIONS_EULA_ACCEPTED_NOTIFIER_H_
#include "base/basictypes.h"
// Interface for querying the EULA accepted state and receiving a notification
// when the EULA is accepted. This abstracts away the platform-specific logic
// for EULA notifications on different platforms.
class EulaAcceptedNotifier {
public:
// Observes EULA accepted state changes.
class Observer {
public:
virtual void OnEulaAccepted() = 0;
};
EulaAcceptedNotifier();
virtual ~EulaAcceptedNotifier();
// Initializes this class with the given |observer|. Must be called before
// the class is used.
void Init(Observer* observer);
// Returns true if the EULA has been accepted. If the EULA has not yet been
// accepted, begins monitoring the EULA state and will notify the observer
// once the EULA has been accepted.
virtual bool IsEulaAccepted() = 0;
// Factory method for this class.
static EulaAcceptedNotifier* Create();
protected:
// Notifies the observer that the EULA has been updated, to be called by
// platform-specific subclasses.
void NotifyObserver();
private:
// Observer of the EULA accepted notification.
Observer* observer_;
DISALLOW_COPY_AND_ASSIGN(EulaAcceptedNotifier);
};
#endif // CHROME_BROWSER_METRICS_VARIATIONS_EULA_ACCEPTED_NOTIFIER_H_
// Copyright (c) 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 "chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
EulaAcceptedNotifierChromeos::EulaAcceptedNotifierChromeos() {
}
EulaAcceptedNotifierChromeos::~EulaAcceptedNotifierChromeos() {
}
bool EulaAcceptedNotifierChromeos::IsEulaAccepted() {
if (chromeos::WizardController::IsEulaAccepted())
return true;
// Register for the notification, if this is the first time.
if (registrar_.IsEmpty()) {
// Note that this must listen on AllSources due to the difficulty in knowing
// when the WizardController instance is created, and to avoid over-coupling
// the Chrome OS code with the VariationsService by directly attaching as an
// observer. This is OK because WizardController is essentially a singleton.
registrar_.Add(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED,
content::NotificationService::AllSources());
}
return false;
}
void EulaAcceptedNotifierChromeos::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED, type);
// This should only ever be received once. Remove it after this call.
DCHECK(!registrar_.IsEmpty());
registrar_.Remove(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED,
content::NotificationService::AllSources());
NotifyObserver();
}
// static
EulaAcceptedNotifier* EulaAcceptedNotifier::Create() {
#if defined(GOOGLE_CHROME_BUILD)
return new EulaAcceptedNotifierChromeos;
#else
return NULL;
#endif
}
// Copyright (c) 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.
#ifndef CHROME_BROWSER_METRICS_VARIATIONS_EULA_ACCEPTED_NOTIFIER_CHROMEOS_H_
#define CHROME_BROWSER_METRICS_VARIATIONS_EULA_ACCEPTED_NOTIFIER_CHROMEOS_H_
#include "chrome/browser/metrics/variations/eula_accepted_notifier.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
// ChromeOS implementation of the EulaAcceptedNotifier.
class EulaAcceptedNotifierChromeos : public EulaAcceptedNotifier,
public content::NotificationObserver {
public:
EulaAcceptedNotifierChromeos();
virtual ~EulaAcceptedNotifierChromeos();
// EulaAcceptedNotifier overrides:
virtual bool IsEulaAccepted() OVERRIDE;
private:
// content::NotificationObserver overrides:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
// Used to listen for the EULA accepted notification.
content::NotificationRegistrar registrar_;
DISALLOW_COPY_AND_ASSIGN(EulaAcceptedNotifierChromeos);
};
#endif // CHROME_BROWSER_METRICS_VARIATIONS_EULA_ACCEPTED_NOTIFIER_CHROMEOS_H_
......@@ -5,21 +5,12 @@
#include "chrome/browser/metrics/variations/resource_request_allowed_notifier.h"
#include "base/command_line.h"
#include "base/metrics/histogram.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/wizard_controller.h"
#endif
ResourceRequestAllowedNotifier::ResourceRequestAllowedNotifier()
: observer_requested_permission_(false),
was_waiting_for_network_(false),
#if defined(OS_CHROMEOS)
was_waiting_for_user_to_accept_eula_(false),
#endif
waiting_for_network_(false),
waiting_for_user_to_accept_eula_(false),
observer_(NULL) {
}
......@@ -36,18 +27,13 @@ void ResourceRequestAllowedNotifier::Init(Observer* observer) {
// Check this state during initialization. It is not expected to change until
// the corresponding notification is received.
was_waiting_for_network_ = net::NetworkChangeNotifier::IsOffline();
#if defined(OS_CHROMEOS)
was_waiting_for_user_to_accept_eula_ = NeedsEulaAcceptance();
if (was_waiting_for_user_to_accept_eula_) {
// Note that this must listen on AllSources due to the difficulty in knowing
// when the WizardController instance is created, and to avoid over-coupling
// the Chrome OS code with the VariationsService by directly attaching as an
// observer. This is OK because WizardController is essentially a singleton.
registrar_.Add(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED,
content::NotificationService::AllSources());
waiting_for_network_ = net::NetworkChangeNotifier::IsOffline();
eula_notifier_.reset(CreateEulaNotifier());
if (eula_notifier_) {
eula_notifier_->Init(this);
waiting_for_user_to_accept_eula_ = !eula_notifier_->IsEulaAccepted();
}
#endif
}
bool ResourceRequestAllowedNotifier::ResourceRequestsAllowed() {
......@@ -60,24 +46,18 @@ bool ResourceRequestAllowedNotifier::ResourceRequestsAllowed() {
// set a flag to remind this class to notify the observer once the criteria
// is met.
observer_requested_permission_ = true;
return
#if defined(OS_CHROMEOS)
!was_waiting_for_user_to_accept_eula_ &&
#endif
!was_waiting_for_network_;
return !waiting_for_user_to_accept_eula_ && !waiting_for_network_;
}
void ResourceRequestAllowedNotifier::
SetWasWaitingForNetworkForTesting(bool waiting) {
was_waiting_for_network_ = waiting;
void ResourceRequestAllowedNotifier::SetWaitingForNetworkForTesting(
bool waiting) {
waiting_for_network_ = waiting;
}
#if defined(OS_CHROMEOS)
void ResourceRequestAllowedNotifier::
SetWasWaitingForEulaForTesting(bool waiting) {
was_waiting_for_user_to_accept_eula_ = waiting;
void ResourceRequestAllowedNotifier::SetWaitingForEulaForTesting(
bool waiting) {
waiting_for_user_to_accept_eula_ = waiting;
}
#endif
void ResourceRequestAllowedNotifier::MaybeNotifyObserver() {
// Need to ensure that all criteria are met before notifying observers.
......@@ -90,16 +70,18 @@ void ResourceRequestAllowedNotifier::MaybeNotifyObserver() {
}
}
#if defined(OS_CHROMEOS)
bool ResourceRequestAllowedNotifier::NeedsEulaAcceptance() {
#if defined(GOOGLE_CHROME_BUILD)
return !chromeos::WizardController::IsEulaAccepted();
#else
// On unofficial builds, there is no notion of a EULA.
return false;
#endif
EulaAcceptedNotifier* ResourceRequestAllowedNotifier::CreateEulaNotifier() {
return EulaAcceptedNotifier::Create();
}
void ResourceRequestAllowedNotifier::OnEulaAccepted() {
// This flag should have been set if this was waiting on the EULA
// notification.
DCHECK(waiting_for_user_to_accept_eula_);
DVLOG(1) << "EULA was accepted.";
waiting_for_user_to_accept_eula_ = false;
MaybeNotifyObserver();
}
#endif
void ResourceRequestAllowedNotifier::OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) {
......@@ -109,30 +91,10 @@ void ResourceRequestAllowedNotifier::OnConnectionTypeChanged(
// waiting on the network, or if the network changes from one online state
// to another (for example, Wifi to 3G, or Wifi to Wifi, if the network were
// flaky).
if (was_waiting_for_network_ &&
if (waiting_for_network_ &&
type != net::NetworkChangeNotifier::CONNECTION_NONE) {
was_waiting_for_network_ = false;
waiting_for_network_ = false;
DVLOG(1) << "Network came back online.";
MaybeNotifyObserver();
}
}
#if defined(OS_CHROMEOS)
void ResourceRequestAllowedNotifier::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED, type);
// This should only ever be received once. Remove it after this call.
DCHECK(!registrar_.IsEmpty());
registrar_.Remove(this, chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED,
content::NotificationService::AllSources());
// This flag should have been set if this was waiting on the EULA
// notification.
DCHECK(was_waiting_for_user_to_accept_eula_);
DVLOG(1) << "EULA was accepted.";
was_waiting_for_user_to_accept_eula_ = false;
MaybeNotifyObserver();
}
#endif
......@@ -5,13 +5,9 @@
#ifndef CHROME_BROWSER_METRICS_VARIATIONS_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
#define CHROME_BROWSER_METRICS_VARIATIONS_RESOURCE_REQUEST_ALLOWED_NOTIFIER_H_
#include "chrome/browser/metrics/variations/eula_accepted_notifier.h"
#include "net/base/network_change_notifier.h"
#if defined(OS_CHROMEOS)
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#endif
// This class informs an interested observer when resource requests over the
// network are permitted.
//
......@@ -32,11 +28,9 @@
// Note that this class handles the criteria state for a single service, so
// services should keep their own instance of this class rather than sharing a
// global instance.
class ResourceRequestAllowedNotifier :
#if defined(OS_CHROMEOS)
public content::NotificationObserver,
#endif
public net::NetworkChangeNotifier::ConnectionTypeObserver {
class ResourceRequestAllowedNotifier
: public EulaAcceptedNotifier::Observer,
public net::NetworkChangeNotifier::ConnectionTypeObserver {
public:
// Observes resource request allowed state changes.
class Observer {
......@@ -56,57 +50,42 @@ class ResourceRequestAllowedNotifier :
// Returns true iff all resource request criteria are met. If not, this call
// will set some flags so it knows to notify the observer if the criteria
// changes. Note that the observer will never be notified unless it calls this
// method first. This is virtual so it can be overriden for tests.
// method first. This is virtual so it can be overridden for tests.
virtual bool ResourceRequestsAllowed();
void SetWasWaitingForNetworkForTesting(bool waiting);
#if defined(OS_CHROMEOS)
void SetWasWaitingForEulaForTesting(bool waiting);
#endif
void SetWaitingForNetworkForTesting(bool waiting);
void SetWaitingForEulaForTesting(bool waiting);
protected:
// Notifies the observer if all criteria needed for resource requests are met.
// This is protected so it can be called from subclasses for testing.
void MaybeNotifyObserver();
#if defined(OS_CHROMEOS)
// On official builds, returns true iff the EULA needs to be accepted. This
// always returns false on unofficial builds since there is no notion of a
// EULA.
//
// This is virtual so it can be overriden by test classes to avoid making them
// aware of the ChromeOS details. This is protected so it call be overriden in
// subclasses for testing.
virtual bool NeedsEulaAcceptance();
#endif
private:
// Creates the EulaAcceptNotifier or NULL if one is not needed. Virtual so
// that it can be overridden by test subclasses.
virtual EulaAcceptedNotifier* CreateEulaNotifier();
// EulaAcceptedNotifier::Observer overrides:
virtual void OnEulaAccepted() OVERRIDE;
// net::NetworkChangeNotifier::ConnectionTypeObserver overrides:
virtual void OnConnectionTypeChanged(
net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
#if defined(OS_CHROMEOS)
// content::NotificationObserver overrides:
virtual void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
#endif
// Tracks whether or not the observer/service depending on this class actually
// requested permission to make a request or not. If it did not, then this
// class should not notify it even if the criteria is met.
bool observer_requested_permission_;
// Tracks network connectivity criteria.
bool was_waiting_for_network_;
bool waiting_for_network_;
#if defined(OS_CHROMEOS)
// Tracks EULA acceptance criteria.
bool was_waiting_for_user_to_accept_eula_;
bool waiting_for_user_to_accept_eula_;
// Used to listen for the EULA accepted notification.
content::NotificationRegistrar registrar_;
#endif
// Platform-specific notifier of EULA acceptance, or NULL if not needed.
scoped_ptr<EulaAcceptedNotifier> eula_notifier_;
// Observing service interested in request permissions.
Observer* observer_;
......
......@@ -4,22 +4,20 @@
#include "chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.h"
TestRequestAllowedNotifier::TestRequestAllowedNotifier() :
#if defined(OS_CHROMEOS)
needs_eula_acceptance_(true),
#endif
override_requests_allowed_(false),
TestRequestAllowedNotifier::TestRequestAllowedNotifier()
: override_requests_allowed_(false),
requests_allowed_(true) {
}
TestRequestAllowedNotifier::~TestRequestAllowedNotifier() {
}
#if defined(OS_CHROMEOS)
void TestRequestAllowedNotifier::SetNeedsEulaAcceptance(bool needs_acceptance) {
needs_eula_acceptance_ = needs_acceptance;
void TestRequestAllowedNotifier::InitWithEulaAcceptNotifier(
Observer* observer,
scoped_ptr<EulaAcceptedNotifier> eula_notifier) {
test_eula_notifier_.swap(eula_notifier);
Init(observer);
}
#endif
void TestRequestAllowedNotifier::SetRequestsAllowedOverride(bool allowed) {
override_requests_allowed_ = true;
......@@ -45,8 +43,7 @@ bool TestRequestAllowedNotifier::ResourceRequestsAllowed() {
return requests_allowed;
}
#if defined(OS_CHROMEOS)
bool TestRequestAllowedNotifier::NeedsEulaAcceptance() {
return needs_eula_acceptance_;
EulaAcceptedNotifier* TestRequestAllowedNotifier::CreateEulaNotifier() {
return test_eula_notifier_.release();
}
#endif
......@@ -21,9 +21,10 @@ class TestRequestAllowedNotifier : public ResourceRequestAllowedNotifier {
TestRequestAllowedNotifier();
virtual ~TestRequestAllowedNotifier();
#if defined(OS_CHROMEOS)
void SetNeedsEulaAcceptance(bool needs_acceptance);
#endif
// A version of |Init()| that accepts a custom EulaAcceptedNotifier.
void InitWithEulaAcceptNotifier(
Observer* observer,
scoped_ptr<EulaAcceptedNotifier> eula_notifier);
// Makes ResourceRequestsAllowed return |allowed| when it is called.
void SetRequestsAllowedOverride(bool allowed);
......@@ -32,17 +33,12 @@ class TestRequestAllowedNotifier : public ResourceRequestAllowedNotifier {
// the observer is expecting a notification.
void NotifyObserver();
// ResourceRequestAllowedNotifier overrides:
virtual bool ResourceRequestsAllowed() OVERRIDE;
protected:
#if defined(OS_CHROMEOS)
virtual bool NeedsEulaAcceptance() OVERRIDE;
#endif
virtual EulaAcceptedNotifier* CreateEulaNotifier() OVERRIDE;
private:
#if defined(OS_CHROMEOS)
bool needs_eula_acceptance_;
#endif
scoped_ptr<EulaAcceptedNotifier> test_eula_notifier_;
bool override_requests_allowed_;
bool requests_allowed_;
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/prefs/testing_pref_service.h"
#include "chrome/browser/metrics/variations/eula_accepted_notifier.h"
#include "chrome/browser/metrics/variations/resource_request_allowed_notifier_test_util.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/testing_browser_process.h"
......@@ -40,6 +41,33 @@ class TestNetworkChangeNotifier : public net::NetworkChangeNotifier {
DISALLOW_COPY_AND_ASSIGN(TestNetworkChangeNotifier);
};
// EulaAcceptedNotifier test class that allows mocking the EULA accepted state
// and issuing simulated notifications.
class TestEulaAcceptedNotifier : public EulaAcceptedNotifier {
public:
TestEulaAcceptedNotifier() : eula_accepted_(false) {
}
virtual ~TestEulaAcceptedNotifier() {
}
virtual bool IsEulaAccepted() OVERRIDE {
return eula_accepted_;
}
void SetEulaAcceptedForTesting(bool eula_accepted) {
eula_accepted_ = eula_accepted;
}
void SimulateEulaAccepted() {
NotifyObserver();
}
private:
bool eula_accepted_;
DISALLOW_COPY_AND_ASSIGN(TestEulaAcceptedNotifier);
};
// A test fixture class for ResourceRequestAllowedNotifier tests that require
// network state simulations. This also acts as the service implementing the
// ResourceRequestAllowedNotifier::Observer interface.
......@@ -49,12 +77,10 @@ class ResourceRequestAllowedNotifierTest
public:
ResourceRequestAllowedNotifierTest()
: ui_thread(content::BrowserThread::UI, &message_loop),
eula_notifier_(new TestEulaAcceptedNotifier),
was_notified_(false) {
#if defined(OS_CHROMEOS)
// Set this flag to true so the Init call sets up the wait on the EULA.
SetNeedsEulaAcceptance(true);
#endif
resource_request_allowed_notifier_.Init(this);
resource_request_allowed_notifier_.InitWithEulaAcceptNotifier(
this, scoped_ptr<EulaAcceptedNotifier>(eula_notifier_));
}
virtual ~ResourceRequestAllowedNotifierTest() { }
......@@ -66,9 +92,8 @@ class ResourceRequestAllowedNotifierTest
}
// Network manipulation methods:
void SetWasWaitingForNetwork(bool waiting) {
resource_request_allowed_notifier_.
SetWasWaitingForNetworkForTesting(waiting);
void SetWaitingForNetwork(bool waiting) {
resource_request_allowed_notifier_.SetWaitingForNetworkForTesting(waiting);
}
void SimulateNetworkConnectionChange(
......@@ -81,44 +106,36 @@ class ResourceRequestAllowedNotifierTest
resource_request_allowed_notifier_.ResourceRequestsAllowed();
}
#if defined(OS_CHROMEOS)
// Eula manipulation methods:
void SetNeedsEulaAcceptance(bool needs_acceptance) {
resource_request_allowed_notifier_.SetNeedsEulaAcceptance(needs_acceptance);
void SimulateEulaAccepted() {
eula_notifier_->SimulateEulaAccepted();
}
void SetWasWaitingForEula(bool waiting) {
resource_request_allowed_notifier_.SetWasWaitingForEulaForTesting(waiting);
// Eula manipulation methods:
void SetNeedsEulaAcceptance(bool needs_acceptance) {
eula_notifier_->SetEulaAcceptedForTesting(!needs_acceptance);
}
void SimulateEulaAccepted() {
SetNeedsEulaAcceptance(false);
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_WIZARD_EULA_ACCEPTED,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
void SetWaitingForEula(bool waiting) {
resource_request_allowed_notifier_.SetWaitingForEulaForTesting(waiting);
}
// Used in tests involving the EULA. Disables both the EULA accepted state
// and the network.
void DisableEulaAndNetwork() {
SetWasWaitingForNetwork(true);
SetWaitingForNetwork(true);
SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_NONE);
SetWasWaitingForEula(true);
SetWaitingForEula(true);
SetNeedsEulaAcceptance(true);
}
#endif
virtual void SetUp() OVERRIDE {
// Assume the test service has already requested permission, as all tests
// just test that criteria changes notify the server.
#if defined(OS_CHROMEOS)
// Set default EULA state to done (not waiting and EULA accepted) to
// simplify non-ChromeOS tests.
SetWasWaitingForEula(false);
SetWaitingForEula(false);
SetNeedsEulaAcceptance(false);
#endif
}
private:
......@@ -126,6 +143,7 @@ class ResourceRequestAllowedNotifierTest
content::TestBrowserThread ui_thread;
TestNetworkChangeNotifier network_notifier;
TestRequestAllowedNotifier resource_request_allowed_notifier_;
TestEulaAcceptedNotifier* eula_notifier_; // Weak, owned by RRAN.
bool was_notified_;
DISALLOW_COPY_AND_ASSIGN(ResourceRequestAllowedNotifierTest);
......@@ -133,14 +151,14 @@ class ResourceRequestAllowedNotifierTest
TEST_F(ResourceRequestAllowedNotifierTest, DoNotNotifyIfOffline) {
SimulateResourceRequest();
SetWasWaitingForNetwork(true);
SetWaitingForNetwork(true);
SimulateNetworkConnectionChange(net::NetworkChangeNotifier::CONNECTION_NONE);
EXPECT_FALSE(was_notified());
}
TEST_F(ResourceRequestAllowedNotifierTest, DoNotNotifyIfOnlineToOnline) {
SimulateResourceRequest();
SetWasWaitingForNetwork(false);
SetWaitingForNetwork(false);
SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_ETHERNET);
EXPECT_FALSE(was_notified());
......@@ -148,7 +166,7 @@ TEST_F(ResourceRequestAllowedNotifierTest, DoNotNotifyIfOnlineToOnline) {
TEST_F(ResourceRequestAllowedNotifierTest, NotifyOnReconnect) {
SimulateResourceRequest();
SetWasWaitingForNetwork(true);
SetWaitingForNetwork(true);
SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_ETHERNET);
EXPECT_TRUE(was_notified());
......@@ -156,7 +174,7 @@ TEST_F(ResourceRequestAllowedNotifierTest, NotifyOnReconnect) {
TEST_F(ResourceRequestAllowedNotifierTest, NoNotifyOnWardriving) {
SimulateResourceRequest();
SetWasWaitingForNetwork(false);
SetWaitingForNetwork(false);
SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_WIFI);
EXPECT_FALSE(was_notified());
......@@ -173,7 +191,7 @@ TEST_F(ResourceRequestAllowedNotifierTest, NoNotifyOnWardriving) {
TEST_F(ResourceRequestAllowedNotifierTest, NoNotifyOnFlakyConnection) {
SimulateResourceRequest();
SetWasWaitingForNetwork(false);
SetWaitingForNetwork(false);
SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_WIFI);
EXPECT_FALSE(was_notified());
......@@ -189,13 +207,12 @@ TEST_F(ResourceRequestAllowedNotifierTest, NoRequestNoNotify) {
// Ensure that if the observing service does not request access, it does not
// get notified, even if the criteria is met. Note that this is done by not
// calling SimulateResourceRequest here.
SetWasWaitingForNetwork(true);
SetWaitingForNetwork(true);
SimulateNetworkConnectionChange(
net::NetworkChangeNotifier::CONNECTION_ETHERNET);
EXPECT_FALSE(was_notified());
}
#if defined(OS_CHROMEOS)
TEST_F(ResourceRequestAllowedNotifierTest, EulaOnlyNetworkOffline) {
SimulateResourceRequest();
DisableEulaAndNetwork();
......@@ -241,4 +258,3 @@ TEST_F(ResourceRequestAllowedNotifierTest, NoRequestNoNotifyEula) {
SimulateEulaAccepted();
EXPECT_FALSE(was_notified());
}
#endif // OS_CHROMEOS
......@@ -975,6 +975,10 @@
'browser/metrics/tracking_synchronizer.cc',
'browser/metrics/tracking_synchronizer.h',
'browser/metrics/tracking_synchronizer_observer.h',
'browser/metrics/variations/eula_accepted_notifier.cc',
'browser/metrics/variations/eula_accepted_notifier.h',
'browser/metrics/variations/eula_accepted_notifier_chromeos.cc',
'browser/metrics/variations/eula_accepted_notifier_chromeos.h',
'browser/metrics/variations/network_time_tracker.cc',
'browser/metrics/variations/network_time_tracker.h',
'browser/metrics/variations/resource_request_allowed_notifier.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment