1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_CHROMEOS_SCOPED_FAKE_ASH_PROXY_H_
#define REMOTING_HOST_CHROMEOS_SCOPED_FAKE_ASH_PROXY_H_
#include <string>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "remoting/host/chromeos/ash_proxy.h"
#include "services/viz/privileged/mojom/compositing/frame_sink_video_capture.mojom.h"
namespace remoting::test {
// Simple basic implementation of |AshProxy|.
// Will automatically register itself as the global version in the constructor,
// and deregister in the destructor.
class ScopedFakeAshProxy : public AshProxy {
public:
static constexpr DisplayId kDefaultPrimaryDisplayId = 12345678901;
ScopedFakeAshProxy();
// It's the responsibility of the caller to ensure this
// SecurityCurtainController outlives ScopedFakeAshProxy.
explicit ScopedFakeAshProxy(
ash::curtain::SecurityCurtainController* controller);
ScopedFakeAshProxy(const ScopedFakeAshProxy&) = delete;
ScopedFakeAshProxy& operator=(const ScopedFakeAshProxy&) = delete;
~ScopedFakeAshProxy() override;
display::Display& AddPrimaryDisplay(DisplayId id = kDefaultPrimaryDisplayId);
display::Display& AddPrimaryDisplayFromSpec(
const std::string& spec,
DisplayId id = kDefaultPrimaryDisplayId);
bool HasPrimaryDisplay() const;
display::Display& AddDisplayWithId(DisplayId id);
void RemoveDisplay(DisplayId id);
void UpdateDisplaySpec(DisplayId id, const std::string& spec);
void UpdatePrimaryDisplaySpec(const std::string& spec);
// Create a display with the given specifications.
// See display::ManagedDisplayInfo::CreateFromSpec for details of the
// specification string.
display::Display& AddDisplayFromSpecWithId(const std::string& spec,
DisplayId id);
// AshProxy implementation:
DisplayId GetPrimaryDisplayId() const override;
const std::vector<display::Display>& GetActiveDisplays() const override;
const display::Display* GetDisplayForId(DisplayId display_id) const override;
aura::Window* GetSelectFileContainer() override;
ash::curtain::SecurityCurtainController& GetSecurityCurtainController()
override;
void CreateVideoCapturer(
mojo::PendingReceiver<viz::mojom::FrameSinkVideoCapturer> video_capturer)
override;
aura::ScopedWindowCaptureRequest MakeDisplayCapturable(
DisplayId source_display_id) override;
viz::FrameSinkId GetFrameSinkId(DisplayId source_display_id) override;
void SetVideoCapturerReceiver(
mojo::Receiver<viz::mojom::FrameSinkVideoCapturer>* receiver);
void RequestSignOut() override;
bool IsScreenReaderEnabled() const override;
int request_sign_out_count() const;
private:
display::Display& AddDisplay(display::Display new_display);
DisplayId primary_display_id_ = -1;
std::vector<display::Display> displays_;
raw_ptr<mojo::Receiver<viz::mojom::FrameSinkVideoCapturer>> receiver_ =
nullptr;
raw_ptr<ash::curtain::SecurityCurtainController> security_curtain_controller_;
int request_sign_out_count_ = 0;
};
} // namespace remoting::test
#endif // REMOTING_HOST_CHROMEOS_SCOPED_FAKE_ASH_PROXY_H_
|