Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change from Mock to Fake for KioskAppLauncher
This change will a) make the tests follow a clearer logical structure of doSomething first, then validate the expected effect. b) it allows to prepare for the future case where app_launcher_ can be null before a certain operation is run, so we cannot set expectations on that object yet. Bug: b:256596278 Test: KioskLaunchControllerTest Change-Id: I69f29dbda0eff4ae3e95d4a00096df478c7c431e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4188537 Reviewed-by: Roland Bock <rbock@google.com> Reviewed-by: Jeroen Dhollander <jeroendh@google.com> Commit-Queue: Ben Franz <bfranz@chromium.org> Cr-Commit-Position: refs/heads/main@{#1097307}
- Loading branch information
Showing
6 changed files
with
155 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/ash/app_mode/fake_kiosk_app_launcher.h" | ||
#include "chrome/browser/ash/app_mode/kiosk_app_launcher.h" | ||
|
||
namespace ash { | ||
|
||
FakeKioskAppLauncher::FakeKioskAppLauncher() = default; | ||
FakeKioskAppLauncher::~FakeKioskAppLauncher() = default; | ||
|
||
void FakeKioskAppLauncher::AddObserver(KioskAppLauncher::Observer* observer) { | ||
observers_.AddObserver(observer); | ||
} | ||
|
||
void FakeKioskAppLauncher::RemoveObserver( | ||
KioskAppLauncher::Observer* observer) { | ||
observers_.RemoveObserver(observer); | ||
} | ||
|
||
void FakeKioskAppLauncher::Initialize() { | ||
++initialize_called_; | ||
} | ||
|
||
void FakeKioskAppLauncher::ContinueWithNetworkReady() { | ||
++continue_with_network_ready_called_; | ||
} | ||
|
||
void FakeKioskAppLauncher::LaunchApp() { | ||
++launch_app_called_; | ||
} | ||
|
||
void FakeKioskAppLauncher::RestartLauncher() {} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2023 The Chromium Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
#ifndef CHROME_BROWSER_ASH_APP_MODE_FAKE_KIOSK_APP_LAUNCHER_H_ | ||
#define CHROME_BROWSER_ASH_APP_MODE_FAKE_KIOSK_APP_LAUNCHER_H_ | ||
|
||
#include "chrome/browser/ash/app_mode/kiosk_app_launcher.h" | ||
#include "testing/gmock/include/gmock/gmock.h" | ||
|
||
namespace ash { | ||
|
||
class FakeKioskAppLauncher : public KioskAppLauncher { | ||
public: | ||
FakeKioskAppLauncher(); | ||
~FakeKioskAppLauncher() override; | ||
|
||
// `KioskAppLauncher`: | ||
void AddObserver(KioskAppLauncher::Observer* observer) override; | ||
void RemoveObserver(KioskAppLauncher::Observer* observer) override; | ||
void Initialize() override; | ||
void ContinueWithNetworkReady() override; | ||
void LaunchApp() override; | ||
void RestartLauncher() override; | ||
|
||
void ResetAppLaunched(); | ||
|
||
bool IsInitialized() const { return initialize_called_ > 0; } | ||
bool HasAppLaunched() const { return launch_app_called_ > 0; } | ||
bool HasContinueWithNetworkReadyBeenCalled() const { | ||
return continue_with_network_ready_called_ > 0; | ||
} | ||
int initialize_called() { return initialize_called_; } | ||
int launch_app_called() { return launch_app_called_; } | ||
int continue_with_network_ready_called() { | ||
return continue_with_network_ready_called_; | ||
} | ||
|
||
KioskAppLauncher::ObserverList& observers() { return observers_; } | ||
|
||
private: | ||
KioskAppLauncher::ObserverList observers_; | ||
int initialize_called_ = 0; | ||
int launch_app_called_ = 0; | ||
int continue_with_network_ready_called_ = 0; | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // CHROME_BROWSER_ASH_APP_MODE_FAKE_KIOSK_APP_LAUNCHER_H_ |
34 changes: 0 additions & 34 deletions
34
chrome/browser/ash/app_mode/web_app/mock_web_kiosk_app_launcher.cc
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
chrome/browser/ash/app_mode/web_app/mock_web_kiosk_app_launcher.h
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.