GROUP_TIMELINES_R0: GROUP_TIMELINES_R0-second.patch

File GROUP_TIMELINES_R0-second.patch, 9.0 KB (added by boyan, 16 years ago)

Initial tests for the UI of timelines.

  • src/main/java/org/sophie2/main/func/timelines/TimelinesPalette.java

    ### Eclipse Workspace Patch 1.0
    #P org.sophie2.main.func.timelines
     
     1package org.sophie2.main.func.timelines; 
     2 
     3import javax.swing.JTable; 
     4 
     5import org.sophie2.base.layout.model.TablePalette; 
     6import org.sophie2.core.prolib.interfaces.Prop; 
     7 
     8/** 
     9 * The palette displaying the current timeline. By default in the bottom flap. 
     10 *  
     11 * @author boyan 
     12 */ 
     13public class TimelinesPalette extends TablePalette { 
     14         
     15        @Override 
     16        public Prop<JTable> table() { 
     17                // nothing for now 
     18                return null; 
     19        } 
     20} 
  • src/main/java/org/sophie2/main/func/timelines/MainFuncTimelinesModule.java

     
     1package org.sophie2.main.func.timelines; 
     2 
     3import java.util.List; 
     4 
     5import org.sophie2.base.visual.AutoVisualProvider; 
     6import org.sophie2.core.modularity.SophieExtension; 
     7import org.sophie2.core.modularity.SophieExtensionPoint; 
     8import org.sophie2.core.modularity.SophieModule; 
     9 
     10/** 
     11 * Module class for timeline UI and interactions functionalities. 
     12 *  
     13 * @author boyan 
     14 */ 
     15public class MainFuncTimelinesModule extends SophieModule { 
     16 
     17        @Override 
     18        protected void defineExtensionPoints(List<SophieExtensionPoint<?>> res) { 
     19                // TODO Auto-generated method stub               
     20        } 
     21 
     22        @Override 
     23        protected void defineExtensions(List<SophieExtension<?>> res) { 
     24                AutoVisualProvider.fillExtensions(res, TimelinesTab.class); 
     25                AutoVisualProvider.fillExtensions(res, TimelinesPalette.class);          
     26        } 
     27} 
  • src/test/java/org/sophie2/main/func/timelines/TimelinesUITest.java

     
     1package org.sophie2.main.func.timelines; 
     2 
     3import org.junit.Test; 
     4import org.sophie2.base.model.book.Book; 
     5import org.sophie2.base.model.book.Page; 
     6import org.sophie2.base.model.book.timelines.Timeline; 
     7import org.sophie2.base.visual.BaseVisualElement; 
     8import org.sophie2.base.visual.BaseVisualModule; 
     9import org.sophie2.core.modularity.FakeModuleRegistry; 
     10import org.sophie2.core.testing.IntegrationTestBase; 
     11 
     12/** 
     13 * Tests the user interface and interactivity provided for timelines. 
     14 *  
     15 * @author boyan 
     16 */ 
     17public class TimelinesUITest extends IntegrationTestBase { 
     18 
     19        /** 
     20         * A reference to a page that is needed in the {@link Timeline} constructor. 
     21         */ 
     22        public Page page; 
     23         
     24        /** 
     25         * A reference to the {@link TimelinesPalette}. 
     26         */ 
     27        public TimelinesPalette palette; 
     28 
     29        @SuppressWarnings("unchecked") 
     30        @Override 
     31        public void setUp() throws Exception { 
     32                super.setUp(); 
     33                Book book = Book.createDefaultBook().get(Book.class); 
     34                Page p = new Page(book.getSpace()); 
     35                this.page = p; 
     36 
     37                FakeModuleRegistry.start(BaseVisualModule.class, 
     38                                MainFuncTimelinesModule.class); 
     39                 
     40                DummyElement dummy = new DummyElement(); 
     41                TimelinesPalette tp = dummy.findNearestElement(null, TimelinesPalette.class); 
     42                this.palette = tp; 
     43        } 
     44 
     45        @Override 
     46        public void tearDown() throws Exception { 
     47                this.page.delete(); 
     48                FakeModuleRegistry.stop(); 
     49                super.tearDown(); 
     50        } 
     51 
     52        /** 
     53         * A dummy class for testing purposes. 
     54         *  
     55         * @author boyan 
     56         */ 
     57        public static class DummyElement extends BaseVisualElement { 
     58                // nothing for now 
     59        } 
     60 
     61        /** 
     62         * Tests whether each channel is displayed in the table of the palette. This 
     63         * test should be significantly changed on every UI change. 
     64         */ 
     65        @Test 
     66        public void testChannelsDisplay() { 
     67                Timeline t = new Timeline(this.page);            
     68                assertEquals(t.channels().size(), this.palette.table().get().getRowCount()); 
     69                this.page.addNewFrame("New Frame"); 
     70                assertEquals(t.channels().size(), this.palette.table().get().getRowCount()); 
     71                this.page.frames().get().clear(); 
     72                assertEquals(0, this.palette.table().get().getRowCount()); 
     73        } 
     74 
     75        /** 
     76         * Tests that entries startTime and length are correctly changed when 
     77         * checkboxes in the UI are clicked. 
     78         */ 
     79        @Test 
     80        public void testEntries() { 
     81                // Checks that length corresponds to the default length of the timeline 
     82                // (all checkboxes are checked). 
     83                // Unchecks some of the checkboxes (changes the duration of the entry) 
     84                // and ensures changes are propagated. 
     85        } 
     86 
     87        /** 
     88         * Test navigation through the user interface (play/pause). 
     89         */ 
     90        @Test 
     91        public void testNavigation() { 
     92                // Checks that clicking on play/pause button or loop button 
     93                // actually changes the state of the timeline. 
     94        } 
     95} 
  • src/main/java/org/sophie2/main/func/timelines/TimelinesTab.java

     
     1package org.sophie2.main.func.timelines; 
     2 
     3import org.sophie2.base.layout.model.Tab; 
     4 
     5/** 
     6 * The Timelines tab. 
     7 *  
     8 * @author boyan 
     9 */ 
     10public class TimelinesTab extends Tab { 
     11        // nothing for now 
     12} 
  • pom.xml

     
    1010                <relativePath>../../pom.xml</relativePath> 
    1111        </parent> 
    1212        <groupId>org.sophie2</groupId> 
    13         <artifactId>org.sophie2.proto.project</artifactId> 
     13        <artifactId>org.sophie2.main.func.timelines</artifactId> 
    1414        <version>2.0-SNAPSHOT</version> 
    15         <name>Sophie 2 ProtoProject Component</name> 
     15        <name>Sophie 2 Timelines Manipulation Support</name> 
    1616        <packaging>bundle</packaging> 
    17         <description>Copy from this one to create a sophie2 module</description> 
     17        <description>Provides a UI and interactions for timeline manipulation.</description> 
    1818        <dependencies> 
    19                 <dependency> 
    20                         <groupId>log4j</groupId> 
    21                         <artifactId>log4j</artifactId> 
    22                         <version>1.2.14</version> 
    23                         <type>jar</type> 
    24                         <exclusions> 
    25                                 <exclusion> 
    26                                         <groupId>com.sun.jdmk</groupId> 
    27                                         <artifactId>jmxtools</artifactId> 
    28                                 </exclusion> 
    29                                 <exclusion> 
    30                                         <groupId>com.sun.jmx</groupId> 
    31                                         <artifactId>jmxri</artifactId> 
    32                                 </exclusion> 
    33                         </exclusions> 
    34                 </dependency> 
    35                 <dependency> 
    36                         <groupId>junit</groupId> 
    37                         <artifactId>junit</artifactId> 
    38                         <version>4.4</version> 
    39                         <type>jar</type> 
    40                         <scope>test</scope> 
    41                 </dependency> 
     19                <dependency>  
     20                <groupId>org.sophie2</groupId>  
     21                <artifactId>org.sophie2.core.modularity</artifactId>  
     22                <version>2.0-SNAPSHOT</version>  
     23                </dependency> 
     24                <dependency>  
     25                <groupId>org.sophie2</groupId>  
     26                <artifactId>org.sophie2.base.visual</artifactId>  
     27                <version>2.0-SNAPSHOT</version>  
     28                </dependency> 
     29                <dependency> 
     30                <groupId>org.sophie2</groupId>  
     31                <artifactId>org.sophie2.base.layout</artifactId>  
     32                <version>2.0-SNAPSHOT</version>  
     33                </dependency> 
     34                <dependency> 
     35                <groupId>org.sophie2</groupId>  
     36                <artifactId>org.sophie2.base.model.book</artifactId>  
     37                <version>2.0-SNAPSHOT</version>  
     38                </dependency> 
     39                <dependency> 
     40                <groupId>org.sophie2</groupId>  
     41                <artifactId>org.sophie2.main.app.commons</artifactId>  
     42                <version>2.0-SNAPSHOT</version>  
     43                </dependency> 
     44                <dependency> 
     45                <groupId>org.sophie2</groupId>  
     46                <artifactId>org.sophie2.main.func.links</artifactId>  
     47                <version>2.0-SNAPSHOT</version>  
     48                </dependency> 
    4249        </dependencies> 
    4350        <build> 
    4451                <plugins> 
     
    4956                                <extensions>true</extensions> 
    5057                                <configuration> 
    5158                                        <instructions> 
    52                                                 <!-- 
    53                                                         Uncomment next line and set appropriate main class of the bundle 
    54                                                         if it is runnable Normally only App module should be runnable 
    55                                                 --> 
    56                                                 <!-- <Main-Class>org.sophie2.proto.project.ProtoModule</Main-Class> --> 
    57                                                 <!-- 
    58                                                         Uncomment next line and change to the class extending SopheModule 
    59                                                         if such is available 
    60                                                 --> 
    61                                                 <!-- 
    62                                                         <Bundle-Activator>org.sophie2.proto.project.ProtoModule</Bundle-Activator> 
    63                                                 --> 
    64                                                 <Export-Package>org.sophie2.proto.project.*</Export-Package> 
    65                                                 <!-- 
    66                                                         <Private-Package>org.apache.felix.moduleloader.*,org.apache.felix.framework.*,org.apache.felix.main,org.osgi.*,org.apache.log4j.*</Private-Package> 
    67                                                 --> 
     59                                                <Bundle-Activator>org.sophie2.main.func.timelines.MainFuncTimelinesModule</Bundle-Activator> 
     60                                                <Export-Package>org.sophie2.main.func.timelines.*</Export-Package> 
    6861                                                <Embed-Dependency>*;scope=compile|runtime;groupId=!org.sophie2|org.osgi|log4j</Embed-Dependency> 
    6962                                                <Import-Package>*;resolution:=optional</Import-Package> 
    7063                                        </instructions>