|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.epoc.engine.tests.model; |
|
19 |
|
20 import com.nokia.carbide.cpp.epoc.engine.DocumentFactory; |
|
21 import com.nokia.carbide.cpp.epoc.engine.model.IViewParserConfiguration; |
|
22 import com.nokia.carbide.cpp.epoc.engine.model.MMPModelFactory; |
|
23 import com.nokia.carbide.cpp.epoc.engine.model.mmp.EMMPStatement; |
|
24 import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPOwnedModel; |
|
25 import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPView; |
|
26 import com.nokia.carbide.cpp.epoc.engine.model.mmp.IMMPViewConfiguration; |
|
27 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AcceptedNodesViewFilter; |
|
28 import com.nokia.carbide.cpp.epoc.engine.preprocessor.AllNodesViewFilter; |
|
29 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IDefine; |
|
30 import com.nokia.carbide.cpp.epoc.engine.preprocessor.IViewFilter; |
|
31 import com.nokia.cpp.internal.api.utils.core.Logging; |
|
32 |
|
33 import org.eclipse.core.runtime.ILogListener; |
|
34 import org.eclipse.core.runtime.IPath; |
|
35 import org.eclipse.core.runtime.IStatus; |
|
36 import org.eclipse.jface.text.IDocument; |
|
37 |
|
38 import java.util.ArrayList; |
|
39 import java.util.Collection; |
|
40 |
|
41 public abstract class BaseMMPViewTest extends BaseViewTests { |
|
42 |
|
43 protected IPath path; |
|
44 protected IMMPOwnedModel model; |
|
45 protected IMMPViewConfiguration mmpConfig; |
|
46 protected ArrayList<IDefine> macros; |
|
47 protected IMMPViewConfiguration allConfig; |
|
48 protected String defFileBase; |
|
49 protected boolean isEmulator; |
|
50 |
|
51 static boolean[] errors = { false }; |
|
52 static { |
|
53 Logging.addListener(new ILogListener() { |
|
54 public void logging(IStatus status, String plugin) { |
|
55 errors[0] = true; |
|
56 } |
|
57 |
|
58 }); |
|
59 } |
|
60 |
|
61 |
|
62 public BaseMMPViewTest() { |
|
63 super(); |
|
64 } |
|
65 |
|
66 @Override |
|
67 protected void setUp() throws Exception { |
|
68 super.setUp(); |
|
69 |
|
70 this.path = projectPath.append("group/test.mmp"); |
|
71 |
|
72 this.macros = new ArrayList<IDefine>(); |
|
73 |
|
74 errors[0] = false; |
|
75 |
|
76 defFileBase = "BWINS"; |
|
77 isEmulator = true; |
|
78 |
|
79 mmpConfig = new IMMPViewConfiguration() { |
|
80 public boolean isStatementSupported(EMMPStatement statement) { |
|
81 return true; |
|
82 } |
|
83 |
|
84 public IViewFilter getViewFilter() { |
|
85 return new AcceptedNodesViewFilter(); |
|
86 } |
|
87 |
|
88 public Collection<IDefine> getMacros() { |
|
89 return macros; |
|
90 } |
|
91 |
|
92 public IViewParserConfiguration getViewParserConfiguration() { |
|
93 return parserConfig; |
|
94 } |
|
95 |
|
96 public String getDefaultDefFileBase(boolean isASSP) { |
|
97 return defFileBase; |
|
98 } |
|
99 public boolean isEmulatorBuild() { |
|
100 return isEmulator; |
|
101 } |
|
102 }; |
|
103 |
|
104 allConfig = new IMMPViewConfiguration() { |
|
105 public boolean isStatementSupported(EMMPStatement statement) { |
|
106 return true; |
|
107 } |
|
108 |
|
109 public IViewFilter getViewFilter() { |
|
110 return new AllNodesViewFilter(); |
|
111 } |
|
112 |
|
113 public Collection<IDefine> getMacros() { |
|
114 return macros; |
|
115 } |
|
116 |
|
117 public IViewParserConfiguration getViewParserConfiguration() { |
|
118 return parserConfig; |
|
119 } |
|
120 public String getDefaultDefFileBase(boolean isASSP) { |
|
121 return defFileBase; |
|
122 } |
|
123 public boolean isEmulatorBuild() { |
|
124 return isEmulator; |
|
125 } |
|
126 }; |
|
127 } |
|
128 |
|
129 protected void makeModel() { |
|
130 String text = parserConfig.getFilesystem().get(modelPath.lastSegment()); |
|
131 IDocument document = DocumentFactory.createDocument(text); |
|
132 model = new MMPModelFactory().createModel(modelPath, document); |
|
133 |
|
134 model.parse(); |
|
135 } |
|
136 |
|
137 protected void makeModel(String text) { |
|
138 IDocument document = DocumentFactory.createDocument(text); |
|
139 model = new MMPModelFactory().createModel(path, document); |
|
140 |
|
141 model.parse(); |
|
142 } |
|
143 |
|
144 protected IMMPView getView(IMMPViewConfiguration config) { |
|
145 IMMPView view = (IMMPView) model.createView(config); |
|
146 assertNotNull(view); |
|
147 return view; |
|
148 } |
|
149 |
|
150 protected void commitTest(IMMPView view, String refText) { |
|
151 commitTest(model, view, refText); |
|
152 } |
|
153 |
|
154 } |