[Buix-commits] r448 - trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui
Author: tchemit Date: 2008-04-11 03:34:09 +0000 (Fri, 11 Apr 2008) New Revision: 448 Modified: trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java Log: use EntryGenerator Modified: trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java =================================================================== --- trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-11 03:33:34 UTC (rev 447) +++ trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-11 03:34:09 UTC (rev 448) @@ -1,5 +1,5 @@ /** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * ##% Copyright (C) 2008 Code Lutin, Tony Chemit * This program is free software; you * can redistribute it and/or modify it under the terms of the GNU General * Public License as published by the Free Software Foundation; either version 2 @@ -10,57 +10,68 @@ * should have received a copy of the GNU General Public License along with this * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place * - Suite 330, Boston, MA 02111-1307, USA. - * # #% + * ##% */ package org.codelutin.vcs.ui; import org.codelutin.i18n.I18n; import org.codelutin.vcs.VCSConnexion; -import org.codelutin.vcs.VCSEntry; +import org.codelutin.vcs.VCSConnexionConfig; +import org.codelutin.vcs.VCSException; import org.codelutin.vcs.VCSFactory; import org.codelutin.vcs.type.VCSConnexionMode; -import org.codelutin.vcs.type.VCSEntryLocation; -import org.codelutin.vcs.type.VCSState; -import org.codelutin.vcs.ui.model.SynchUIModel; +import org.codelutin.vcs.ui.SynchUI; +import org.codelutin.vcs.ui.util.AbstractTabUIModel; import org.codelutin.vcs.util.VCSConnexionConfigImpl; -import org.codelutin.vcs.util.VCSEntryImpl; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; -import java.util.ArrayList; -import java.util.List; +import java.io.IOException; /** @author chemit */ public class UITest { - /** The r. */ - static java.util.Random r = new java.util.Random(); + public static void main(String[] args) throws IOException, VCSException { - public static void main(String[] args) { - I18n.init(); - final VCSConnexion connexion = initVCS(new File(new File("").getAbsolutePath())); + final RepositoryGenerator generator = new RepositoryGenerator(); + final File root = generator.generateWorkingRepositoryPath(); + + generator.generateWorkingRepository(root, 10, 5, 10, 100); + + final VCSConnexion connexion = initMockVCS(root); + connexion.open(); - AbstractSynchUI ui = VCSUIFactory.newSynchUI(); + SynchUI ui = VCSUIFactory.newSynchUI(); - fillSynchModel(connexion, ui.getModel(), 20, "trunk", "local/", "remote/"); + AbstractTabUIModel model = ui.getHandler().getModel(); + model.populate(connexion); + + generator.generateStates(model.getEntriesModel()); + ui.setVisible(true); ui.addWindowListener(new WindowAdapter() { + boolean wasClosed = false; + @Override public void windowClosed(WindowEvent e) { + if (wasClosed) { + return; + } connexion.close(); + generator.deleteWorkingCopy(root); + wasClosed = true; } }); - } - public static VCSConnexion initVCS(File root) { - VCSConnexionConfigImpl config = new VCSConnexionConfigImpl(); + public static VCSConnexion initMockVCS(File root) { + VCSConnexionConfig config = new VCSConnexionConfigImpl(); config.setType("MOCK"); config.setLocalDatabasePath(root); VCSConnexion connexion = VCSFactory.newConnexion(VCSConnexionMode.ANONYMOUS, config); @@ -68,32 +79,4 @@ return connexion; } - protected static void fillSynchModel(VCSConnexion handler, SynchUIModel model, int max, String prefix, String localPRefix, String remotePrefix) { - List<VCSEntry> datas = generateListFileStates(handler, max, prefix, localPRefix, remotePrefix); - model.populate(VCSEntryLocation.UNKNOW, datas.toArray(new VCSEntry[datas.size()])); - } - - protected static List<VCSEntry> generateListFileStates(VCSConnexion handler, int max, String prefix, String localPRefix, String remotePrefix) { - List<VCSEntry> datas = generateLocalFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), localPRefix); - datas.addAll(generateRemoteFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), remotePrefix)); - return datas; - } - - protected static List<VCSEntry> generateLocalFileStates(VCSConnexion handler, int max, File root, String localPRefix) { - return generateFileStates(handler, root, max, localPRefix, VCSState.MODIFIED, VCSState.UNVERSIONNED, VCSState.OUT_OF_DATE_AND_MODIFIED, VCSState.REMOVED); - } - - protected static List<VCSEntry> generateRemoteFileStates(VCSConnexion handler, int max, File root, String remotePRefix) { - return generateFileStates(handler, root, max, remotePRefix, VCSState.MISSING, VCSState.OUT_OF_DATE, VCSState.OUT_OF_DATE_AND_MODIFIED); - } - - protected static List<VCSEntry> generateFileStates(VCSConnexion handler, File root, int max, String prefix, VCSState... states) { - List<VCSEntry> datas = new ArrayList<VCSEntry>(); - for (int i = 0, nbFiles = 1 + r.nextInt(max), size = states.length; i < nbFiles; i++) { - VCSEntry state = new VCSEntryImpl(handler, root.getName() + File.separator + prefix + "file" + i); - state.setState(states[r.nextInt(size)]); - datas.add(state); - } - return datas; - } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org