# Path: core/const.py
# class PaneType:
#     NetWorth = 0
#     Profit = 1
#     Transaction = 2
#     Account = 3
#     Schedule = 4
#     GeneralLedger = 7
#     DocProps = 8
#     PluginList = 9
#     Empty = 100
#     Plugin = 1000
#     ReadOnlyTablePlugin = 1001
# 
# class PaneArea:
#     Main = 1
#     BottomGraph = 2
#     RightChart = 3
# 
# Path: core/gui/main_window.py
# class Preference:
#     OpenedPanes = 'OpenedPanes'
#     SelectedPane = 'SelectedPane'
#     HiddenAreas = 'HiddenAreas'
#     WindowFrame = 'WindowFrame'
# 
# Path: core/tests/base.py
# class PanelViewProvider:
# class ApplicationGUI(CallLogger):
# class DocumentGUI(CallLogger):
# class ViewGUI(CallLogger):
# class MainWindowGUI(CallLogger):
# class DictLoader(base.Loader):
# class TestApp(TestAppBase):
#     def __init__(self):
#     def close_panel(self):
#     def _logify(cls, model, ignore=None):
#     def get_panel_view(self, model):
# def log(method):
#     def wrapper(self, *args, **kw):
#     def __init__(self):
#     def get_default(self, key): # We don't want to log this one. It disturbs other test and is pointless to log
#     def set_default(self, key, value):
#     def __init__(self):
#     def query_for_schedule_scope(self):
#     def __init__(self, panel_view_provider):
#     def get_panel_view(self, model):
#     def __init__(self, testapp):
#     def get_panel_view(self, model):
#     def show_message(self, message):
#     def refresh_panes(self):
#     def __init__(
#             self, default_currency, infos, default_date_format='%d/%m/%Y'):
#     def _parse(self, infile):
#     def _load(self):
#     def __init__(self, app=None, doc=None, appargs=None):
#     def link_gui(self, gui, logger=None):
#     def tmppath(self):
#     def check_current_pane(self, pane_type, account_name=None):
#     def check_gui_calls(gui, *args, **kwargs):
#     def check_gui_calls_partial(gui, *args, **kwargs):
#     def add_account(
#             self, name=None, currency=None, account_type=AccountType.Asset, group_name=None,
#             account_number=None, inactive=None):
#     def add_accounts(self, *names):
#     def add_entry(self, date=None, description=None, payee=None, transfer=None, increase=None,
#             decrease=None, checkno=None, reconciliation_date=None):
#     def add_group(self, name=None, account_type=AccountType.Asset):
#     def add_schedule(self, start_date=None, description='', account=None, amount='0',
#             repeat_type_index=0, repeat_every=1, stop_date=None):
#     def add_txn(self, date=None, description=None, payee=None, from_=None, to=None, amount=None,
#             checkno=None):
#     def add_txn_with_splits(self, splits, date=None, description=None, payee=None, checkno=None):
#     def account_names(self):
#     def account_node_subaccount_count(self, node):
#     def balances(self):
#     def bar_graph_data(self):
#     def close_and_load(self):
#     def change_selected_account(
#             self, name=None, currency=None, account_type=None, account_number=None, inactive=None):
#     def completable_edit(self, attrname):
#     def do_test_save_load(self):
#     def do_test_qif_export_import(self):
#     def entry_descriptions(self):
#     def etable_count(self):
#     def fake_import(self, account_name, transactions, account_reference=None):
#     def get_current_panel(self):
#     def graph_data(self):
#     def navigate_to_date(self, year, month, day):
#     def new_app_same_prefs(self):
#     def nw_graph_data(self):
#     def save_and_load(self):
#     def save_file(self):
#     def select_account(self, account_name):
#     def show_account(self, account_name=None):
#     def set_column_visible(self, colname, visible):
#     def transaction_descriptions(self):
#     def current_view(self):
#     def new_tab(self):
#     def link_aview(self):
#     def show_nwview(self):
#     def show_pview(self):
#     def show_tview(self):
#     def show_aview(self):
#     def show_scview(self):
#     def show_glview(self):
#     def show_dpview(self):
# def compare_apps(first, second, qif_mode=False):
#     def qif_normalize(t):
# def print_table(table, extra_attrs=[]):
#     def getval(row, attrname):
# def Amount(val, currency):


from .testutil import eq_, with_app
from ..const import PaneType, PaneArea
from ..gui.main_window import Preference
from .base import TestApp, testdata
# Copyright 2019 Virgil Dupras
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html

# Tests that make sure preferences are correctly saved/restored



# --- Pristine
@with_app(TestApp)
def test_mainwindow_panes_reopen(app):
    # Main Window panes re-open themselves upon launch, in the same order
    app.mw.close_pane(3) # close schedule pane
    app.add_account('foo')
    app.show_account() # we now have the 'foo' account opened.
    app.mw.move_pane(3, 1) # move the 'foo' pane at the second position
    # The selected pane index is 1
    newapp = app.save_and_load()
    eq_(newapp.mw.current_pane_index, 1) # We've restored the selected pane index
    newapp.check_current_pane(PaneType.Account, account_name='foo')
    newapp.mw.current_pane_index = 2

# Path: core/const.py
# class PaneType:
#     NetWorth = 0
#     Profit = 1
#     Transaction = 2
#     Account = 3
#     Schedule = 4
#     GeneralLedger = 7
#     DocProps = 8
#     PluginList = 9
#     Empty = 100
#     Plugin = 1000
#     ReadOnlyTablePlugin = 1001
# 
# class PaneArea:
#     Main = 1
#     BottomGraph = 2
#     RightChart = 3
# 
# Path: core/gui/main_window.py
# class Preference:
#     OpenedPanes = 'OpenedPanes'
#     SelectedPane = 'SelectedPane'
#     HiddenAreas = 'HiddenAreas'
#     WindowFrame = 'WindowFrame'
# 
# Path: core/tests/base.py
# class PanelViewProvider:
# class ApplicationGUI(CallLogger):
# class DocumentGUI(CallLogger):
# class ViewGUI(CallLogger):
# class MainWindowGUI(CallLogger):
# class DictLoader(base.Loader):
# class TestApp(TestAppBase):
#     def __init__(self):
#     def close_panel(self):
#     def _logify(cls, model, ignore=None):
#     def get_panel_view(self, model):
# def log(method):
#     def wrapper(self, *args, **kw):
#     def __init__(self):
#     def get_default(self, key): # We don't want to log this one. It disturbs other test and is pointless to log
#     def set_default(self, key, value):
#     def __init__(self):
#     def query_for_schedule_scope(self):
#     def __init__(self, panel_view_provider):
#     def get_panel_view(self, model):
#     def __init__(self, testapp):
#     def get_panel_view(self, model):
#     def show_message(self, message):
#     def refresh_panes(self):
#     def __init__(
#             self, default_currency, infos, default_date_format='%d/%m/%Y'):
#     def _parse(self, infile):
#     def _load(self):
#     def __init__(self, app=None, doc=None, appargs=None):
#     def link_gui(self, gui, logger=None):
#     def tmppath(self):
#     def check_current_pane(self, pane_type, account_name=None):
#     def check_gui_calls(gui, *args, **kwargs):
#     def check_gui_calls_partial(gui, *args, **kwargs):
#     def add_account(
#             self, name=None, currency=None, account_type=AccountType.Asset, group_name=None,
#             account_number=None, inactive=None):
#     def add_accounts(self, *names):
#     def add_entry(self, date=None, description=None, payee=None, transfer=None, increase=None,
#             decrease=None, checkno=None, reconciliation_date=None):
#     def add_group(self, name=None, account_type=AccountType.Asset):
#     def add_schedule(self, start_date=None, description='', account=None, amount='0',
#             repeat_type_index=0, repeat_every=1, stop_date=None):
#     def add_txn(self, date=None, description=None, payee=None, from_=None, to=None, amount=None,
#             checkno=None):
#     def add_txn_with_splits(self, splits, date=None, description=None, payee=None, checkno=None):
#     def account_names(self):
#     def account_node_subaccount_count(self, node):
#     def balances(self):
#     def bar_graph_data(self):
#     def close_and_load(self):
#     def change_selected_account(
#             self, name=None, currency=None, account_type=None, account_number=None, inactive=None):
#     def completable_edit(self, attrname):
#     def do_test_save_load(self):
#     def do_test_qif_export_import(self):
#     def entry_descriptions(self):
#     def etable_count(self):
#     def fake_import(self, account_name, transactions, account_reference=None):
#     def get_current_panel(self):
#     def graph_data(self):
#     def navigate_to_date(self, year, month, day):
#     def new_app_same_prefs(self):
#     def nw_graph_data(self):
#     def save_and_load(self):
#     def save_file(self):
#     def select_account(self, account_name):
#     def show_account(self, account_name=None):
#     def set_column_visible(self, colname, visible):
#     def transaction_descriptions(self):
#     def current_view(self):
#     def new_tab(self):
#     def link_aview(self):
#     def show_nwview(self):
#     def show_pview(self):
#     def show_tview(self):
#     def show_aview(self):
#     def show_scview(self):
#     def show_glview(self):
#     def show_dpview(self):
# def compare_apps(first, second, qif_mode=False):
#     def qif_normalize(t):
# def print_table(table, extra_attrs=[]):
#     def getval(row, attrname):
# def Amount(val, currency):


# Path: core/tests/pref_test.py
from .testutil import eq_, with_app
from ..const import PaneType, PaneArea
from ..gui.main_window import Preference
from .base import TestApp, testdata

# Copyright 2019 Virgil Dupras
#
# This software is licensed under the "GPLv3" License as described in the "LICENSE" file,
# which should be included with this package. The terms are also available at
# http://www.gnu.org/licenses/gpl-3.0.html

# Tests that make sure preferences are correctly saved/restored



# --- Pristine
@with_app(TestApp)
def test_mainwindow_panes_reopen(app):
    # Main Window panes re-open themselves upon launch, in the same order
    app.mw.close_pane(3) # close schedule pane
    app.add_account('foo')
    app.show_account() # we now have the 'foo' account opened.
    app.mw.move_pane(3, 1) # move the 'foo' pane at the second position
    # The selected pane index is 1
    newapp = app.save_and_load()
    eq_(newapp.mw.current_pane_index, 1) # We've restored the selected pane index
    newapp.check_current_pane(PaneType.Account, account_name='foo')
    newapp.mw.current_pane_index = 2

    newapp.check_current_pane(PaneType.Profit)