## Summary of the Pull Request Fix the `TabTests`, and enable testing of types with XAML content. The `TabTests` were written many, many moons ago. they were intended to be our tests of XAML-like content within the Terminal app, so we could have unittests of Tabs, Panes, etc. Between their initial authoring and the day they were checked in, we had a bunch of build changes come in and break them irreperably. We've gotten them fixed now with _one weird trick_ <sup>doctors hate me</sup>. As long as there isn't an `App.xbf` in the test's output directory, then the tests will deploy just fine. We also needed a bit of magic, cribbed straight from TAEF, to enable running test code synchronously on the UI thread. Hence, `CppwinrtTailored.h`. ## References ## PR Checklist * [x] Closes #2472 * [x] I work here * [x] Tests added/passed - you better believe it * [n/a] Requires documentation to be updated ## Validation Steps Performed ![image](https://user-images.githubusercontent.com/18356694/70185192-ef1d0b00-16ae-11ea-8799-b77061e3cdb0.png)
57 lines
2.2 KiB
C++
57 lines
2.2 KiB
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#pragma once
|
|
#include "Pane.h"
|
|
|
|
class Tab : public std::enable_shared_from_this<Tab>
|
|
{
|
|
public:
|
|
Tab(const GUID& profile, const winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
|
|
|
// Called after construction to setup events with weak_ptr
|
|
void BindEventHandlers(const winrt::Microsoft::Terminal::TerminalControl::TermControl& control) noexcept;
|
|
|
|
winrt::Microsoft::UI::Xaml::Controls::TabViewItem GetTabViewItem();
|
|
winrt::Windows::UI::Xaml::UIElement GetRootElement();
|
|
winrt::Microsoft::Terminal::TerminalControl::TermControl GetActiveTerminalControl() const;
|
|
std::optional<GUID> GetFocusedProfile() const noexcept;
|
|
|
|
bool IsFocused() const noexcept;
|
|
void SetFocused(const bool focused);
|
|
|
|
void Scroll(const int delta);
|
|
|
|
bool CanSplitPane(winrt::TerminalApp::SplitState splitType);
|
|
void SplitPane(winrt::TerminalApp::SplitState splitType, const GUID& profile, winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
|
|
|
void UpdateIcon(const winrt::hstring iconPath);
|
|
|
|
void ResizeContent(const winrt::Windows::Foundation::Size& newSize);
|
|
void ResizePane(const winrt::TerminalApp::Direction& direction);
|
|
void NavigateFocus(const winrt::TerminalApp::Direction& direction);
|
|
|
|
void UpdateSettings(const winrt::Microsoft::Terminal::Settings::TerminalSettings& settings, const GUID& profile);
|
|
winrt::hstring GetActiveTitle() const;
|
|
void SetTabText(const winrt::hstring& text);
|
|
|
|
void ClosePane();
|
|
|
|
WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);
|
|
DECLARE_EVENT(ActivePaneChanged, _ActivePaneChangedHandlers, winrt::delegate<>);
|
|
|
|
private:
|
|
std::shared_ptr<Pane> _rootPane{ nullptr };
|
|
std::shared_ptr<Pane> _activePane{ nullptr };
|
|
winrt::hstring _lastIconPath{};
|
|
|
|
bool _focused{ false };
|
|
winrt::Microsoft::UI::Xaml::Controls::TabViewItem _tabViewItem{ nullptr };
|
|
|
|
void _MakeTabViewItem();
|
|
void _Focus();
|
|
|
|
void _AttachEventHandlersToControl(const winrt::Microsoft::Terminal::TerminalControl::TermControl& control);
|
|
void _AttachEventHandlersToPane(std::shared_ptr<Pane> pane);
|
|
};
|